Partial and abstract classes
How do you know when to use partial within an abstract class and what is it's function?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 2, 2014, 8:32 AM EST
This is particularly useful when a code generator is generating code for part of the class such as when creating a Form class in Visual Studio.
In the case of an abstract class, I'd have thought it was unlikely that a code generator would be creating part of the class but two or more human programmers might want to work on it simultaneously.
Incidentally, you don't necessarily have to declare all the partial classes as being abstract. If just one is abstract, then so is the whole class.
aresha newalani32 reputationPosted Mar 2, 2014, 9:36 AM EST
VulpesRank #55 · 29.2K reputationPosted Mar 2, 2014, 10:37 AM EST
Notice though that not all methods or properties of an abstract class need be abstract and static members are never abstract.