Do C# 8 default interface implementations allow for multiple inheritanceAsk Questions

 Posted on 8 days ago

According to, one of the new features coming in C# 8 is the default implementation of interfaces. Will this new feature also implicitly allow for multiple inheritance? If not, what exactly will happen if I try the following:

public interface A { int Foo() => 1; }

public interface B { int Foo() => 2; }

public class C : A, B { }


Share On: facebook gplus twitter
Asked by Praful Chauhan on 8 days ago Score: 75 points
Add Comment:


1 Answers

1 Corrected Answers
Aproved Answers
Answered by Will Smith on 9/12/2019 8:09:21 AM Score: 27 points

Note that a class does not inherit members from its interfaces; that is not changed by this feature:

Thus, it seems reasonable (although impossible to confirm with 100% certainty until it is shipped) that:

public interface A { int Foo() => return 1; }
public interface B { int Foo() => return 2; }
public class C : A, B { }

will work fine.

Just as below shows:

new C().M(); // error: class 'C' does not contain a member 'M'

then we can assume, your version:

new C().Foo();

will also not compile.

IA i = new C();

as valid, which is equivalent to your:

A i = new C();

Since i is declared as type A there is no reason to assume the same would not work if A was changed to B - there are no collisions to speak of.

The entire point of this feature is to allow interfaces to be extended in a safe way. If this only worked if you implemented one interface, that seems contrary to the objective of the feature. And given the feature appears to be implemented in a way roughly akin to explicit interface implementation (which is why we can't invoke C.Foo() directly), I think we can reasonably assume that it will most likely allow for multiple interface implementation.


Actually interfaces are still quite far from abstract classes. Classes don’t inherit members from interfaces, so if a class leaves a member M implemented by the interface, the class does not have a member M! It’s like an explicit implementation today; you have to convert to the interface in order to get at such members.
12/09/2019   08:10:17   Praful Chauhan
Add Comment:

Post Your Answers

Existing Members

Sign in to your account
Email Address
New Member?
Sign up and complete profile
Full Name
Email Address
I have read and agree to the Terms of Service and Privacy Policy
Please subscribe me to the StoodQ newsletters
Guideline to answer a question:

Useful tips to submit your answer
Please read below guidelines before you submit your answer for question.

  • Read and understand question for which you are submitting your answer.
  • Try to avoid grammatical and spell mistake while answering.
  • Do not post any irrelevant information in your answer.
  • Explain your answer with example or any reference link to help who posted question.
  • If you find irrelevant question, please report it to support. Click here to contact support.
  • You agree to the privacy policy and terms of use to submit any contents.

Note: StoodQ is online developers community which helps developer for their difficulty, lets help them with your value contribution.