Partial Classes in C#

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

    EDIT: DSL Tools for Visual Studio uses partial classes.

    Thus, it's a feature that many automatic generated code uses. Instead of using #region the automatic generated code goes to one file and the user code (also called custom code) goes to another and even in different directories so that the developer does not get confused with so many meaningless files.

    It's good to have this choice which you can combine - but not forced to use -with inheritance

    Also, it can be handy to separate the logic of some classes among several directories. Of course, for machines, it's the same, but it enhances the user readability experience.

提交回复
热议问题