Partial classes inheriting from a base class
suggest changeWhen inheriting from any base class, only one partial class needs to have the base class specified.
// PartialClass1.cs
public partial class PartialClass : BaseClass {}
// PartialClass2.cs
public partial class PartialClass {}
You can specify the same base class in more than one partial class. It will get flagged as redundant by some IDE tools, but it does compile correctly.
// PartialClass1.cs
public partial class PartialClass : BaseClass {}
// PartialClass2.cs
public partial class PartialClass : BaseClass {} // base class here is redundant
You cannot specify different base classes in multiple partial classes, it will result in a compiler error.
// PartialClass1.cs
public partial class PartialClass : BaseClass {} // compiler error
// PartialClass2.cs
public partial class PartialClass : OtherBaseClass {} // compiler error
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents