Partial classes provides us an option to split classes into multiple parts and in multiple source files. All parts are combined into one single class during compile time. All parts should contain the keyword partial
,should be of the same accessibility. All parts should be present in the same assembly for it to be included during compile time.
Partial classes must be defined within the same assembly, and namespace, as the class that they are extending.
All parts of the class must use the partial
keyword.
All parts of the class must have the same accessibility; public
/protected
/private
etc..
If any part uses the abstract
keyword, then the combined type is considered abstract.
If any part uses the sealed
keyword, then the combined type is considered sealed.
If any part uses the a base type, then the combined type inherits from that type.
The combined type inherits all the interfaces defined on all the partial classes.