Partial class and methods
suggest changeIntroduction
Partial classes provide a way to split a class into multiple parts and multiple source files. All parts are combined into one class at compile time. Every part must use the keyword partial and the same accessibility. All parts must be in the same assembly and the same namespace.
Syntax
- public partial class MyPartialClass { }
Remarks
- Partial classes must be defined within the same assembly and namespace. The parts are one class, not a derived class.
- All parts of the class must use the
partialkeyword. - All parts of the class must have the same accessibility;
public/protected/privateetc.. - If any part uses the
abstractkeyword, then the combined type is considered abstract. - If any part uses the
sealedkeyword, then the combined type is considered sealed. - If any part declares a base type, then the combined type inherits from that type. A type cannot be both
abstractandsealed. - The combined type inherits all the interfaces defined on all the partial classes.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents