Partial Classes in C#

后端 未结 20 2963
时光说笑
时光说笑 2021-02-19 07:59

Are there are good uses of Partial Classes outside the webforms/winforms generated code scenarios? Or is this feature basically to support that?

20条回答
  •  天涯浪人
    2021-02-19 08:53

    Sometimes you might find terribly old code at work that may make it close to impossible to refactor out into distinct elements without breaking existing code.

    When you aren't given the option or the time to create a more genuine architecture, partial classes make it incredibly easy to separate logic where its needed. This allows existing code to continue using the same architecture while you gain a step closer to a more concrete architecture.

提交回复
热议问题