namespace flaseccie
{
using System;
using System.Collections;
public interface ICommon
{
void DoIt();
}
public class Base:ICommon
{
void ICommon.DoIt(){Console.WriteLine("1");}
public virtual void DoIt(){Console.WriteLine("2");}
}
public class Derived:Base,ICommon
{
void ICommon.DoIt(){Console.WriteLine("3");}
public new virtual void DoIt()
{
Console.WriteLine("4");
}
}
public class ReallyDerived:Derived
{
public override void DoIt()
{
Console.WriteLine("5");
}
}
public class MyClass
{
public static void Main()
{
ReallyDerived reDervied=new ReallyDerived();
Derived derived=reDervied;
Base base =reDervied;
ICommon icommon =reDervied;
reDervied.DoIt();
derived.DoIt();
base .DoIt();
icommon .DoIt();
Console.Read();
}
}
}
把你觉得的输入的结果写出来看看。然后解说一下。。。呵。。。
看完上面的后。再看下下面的。
namespace flaseccie
{
using System;
using System.Collections;
public interface ICommon
{
void DoIt();
}
public class Base:ICommon
{
void ICommon.DoIt(){Console.WriteLine("1");}
public virtual void DoIt(){Console.WriteLine("2");}
}
public class Derived:Base,ICommon
{
void ICommon.DoIt(){Console.WriteLine("3");}
public override void DoIt()
{
Console.WriteLine("4");
}
}
public class ReallyDerived:Derived
{
public override void DoIt()
{
Console.WriteLine("5");
}
}
public class MyClass
{
public static void Main()
{
ReallyDerived reDervied=new ReallyDerived();
Derived derived=reDervied;
Base base =reDervied;
ICommon icommon =reDervied;
reDervied.DoIt();
derived.DoIt();
base .DoIt();
icommon .DoIt();
Console.Read();
}
}
}
这样子又是多少呢?