What are the benefits to using a partial class as opposed to an abstract one?

后端 未结 8 1630
花落未央
花落未央 2021-01-18 01:19

I have been reading Programming Microsoft® Visual C#® 2008: The Language to get a better understanding of C# and what can be done with it. I came across partial classes whic

8条回答
  •  有刺的猬
    2021-01-18 01:50

    Partial classes should be restricted to using with auto-generated code, where the other code cannot be modified. Using it as a substitute for inheritance or adding functionality are not best practices.

    If you have a large class, its already wrong. Code should be refactored into multiple "real" classes instead of multiple files. Large classes in general signifies the class is doing too many things and violates SRP (Single Responsibility Principle).

提交回复
热议问题