According to https://blogs.msdn.microsoft.com/dotnet/2018/11/12/building-c-8-0/, 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 { }
Credit to @CodeCaster for his/her great comments that prompted this answer.
The proposal states:
Thus, it seems reasonable (although impossible to confirm with 100% certainty until it is shipped) that:
will work fine.
Just as the proposal shows:
then we can assume, your version:
will also not compile.
The proposal shows:
as valid, which is equivalent to your:
Since
i
is declared as typeA
there is no reason to assume the same would not work ifA
was changed toB
- there are no collisions to speak of.The entire point of this feature is to allow interfaces to be extended in a safe way (see this video). 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.