Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>No, it shouldn't.</p> <p>The call to <code>Hello</code> is equivalent to the commented-out one - the route to getting an <code>IHello</code> doesn't matter (unless it requires execution-time checking or conversion); the compile-time type is just <code>IHello</code> either way, and the interface mapping is the same however you get there.</p> <p>When an interface is explicitly implemented more than once in the type hierarchy, the implementation in the most-derived type is used. (When called via the interface.)</p> <p>From section 13.4.4 of the C# 3.0 Specification:</p> <blockquote> <p>Interface mapping for a class or struct C locates an implementation for each member of each interface specified in the base class list of C. The implementation of a particular interface member I.M, where I is the interface in which the member M is declared, is determined by examining each class or struct S, starting with C and repeating for each successive base class of C, until a match is located:</p> <ul> <li>If S contains a declaration of an explicit interface member implementation that matches I and M, then this member is the implementation of I.M.</li> <li>Otherwise, if S contains a declaration of a non-static public member that matches M, then this member is the implementation of I.M. If more than one member matches, it is unspecified which member is the implementation of I.M. This situation can only occur if S is a constructed type where the two members as declared in the generic type have different signatures, but the type arguments make their signatures identical.</li> </ul> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload