Do C# 8 default interface implementations allow for multiple inheritance

Your question is answered by Mads Torgersen in the blog post you linked to:

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.

So with your example:

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

You cannot do this:

var something = new C();
var x = something.Foo(); /* does not compile */

You can do the following:

var something = new C();
var x = ((A)something).Foo(); /* calls the implementation provided by A */
var y = ((B)something).Foo(); /* calls the implementation provided by B */

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)