As I know, each variable knows about its runtime type.
Here is an example:
void Main()
{
C c = new C();
c.M();
I i = (I)c;
i.M();
}
public interface I
{
void M();
}
public class C : I
{
void I.M()
{
Console.WriteLine("I.M");
}
public void M()
{
Console.WriteLine("M");
}
}
If I understand it right, i
still knows that its type is C
. So, what is the mechanism which lets i
to decide on using I.M
instead of M
?