Partial classes inheriting from a base class

suggest change

When 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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents