override/overload/interface组合测试~
内容来自《.NET本质论》代码如下:
public interface ICommon{void DoIt();}
public class Base : ICommon{
void ICommon.DoIt(){ a(); };
public virtual void DoIt() { b(); }
}
public class Derived : Base , ICommon{
void ICommon.DoIt() { c(); }
public new virtual void DoIt() { d(); }
}
public class ReallyDerived : Derived {
public override void DoIt() { e(); }
}
public static void Main(){
ReallyDerived r1 = new ReallyDerived();
Derived r2 = r1;
Base r3 = r1;
ICommon r4 = r1;
r1.DoIt(); //A
r2.DoIt(); //B
r3.DoIt(); //C
r4.DoIt(); //D
}
上面ABCD四个方法的具体调用分别是{ a();b();c();d();e(); }中的哪一个呢?