What are the benefits to using a partial class as

2020-04-03 04:13发布

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 which I had already encountered from ASP.Net's Page class.

To me it seems that you can do what partial classes do with an abstract class and an overridden one. Obviously one team will be in control of the interface via the abstract methods but you would be relying on each other anyway. And if the goal is collaboration then isn't that what source control and other tools solve.

I am just missing the point to a partial class. Also could someone provide a real world use.

8条回答
我命由我不由天
2楼-- · 2020-04-03 04:53

Purpose of partial classes is to allow a class's definition to span across multiple files. This can allow better maintainability and separation of your code.

查看更多
趁早两清
3楼-- · 2020-04-03 04:54

We use partial classes to split up our larger classes. That way it's easier to check out a part of the code with Sourcesafe. This limits the cases where four developers need to access the same file.

查看更多
登录 后发表回答