Partial Classes in C#

后端 未结 20 2812
广开言路
广开言路 2021-02-19 08:25

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:52

    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.

提交回复
热议问题