Partial Classes in C#

后端 未结 20 2826
广开言路
广开言路 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:39

    It is in part to support scenarios (WebForms, WinForms, LINQ-to-SQL, etc) mixing generated code with programmer code.

    There are more reasons to use it. For example, if you have big classes in large, unwieldy files, but the classes have groups of logically related methods, partial classes may be an option to make your file sizes more manageable.

提交回复
热议问题