interface ITest
{
void Test();
}class A: ITest
{
public void Test()
{
Console.WriteLine("A test!");
}
}class B : A, ITest
{
public void Paint()
{
Console.WriteLine("B test!");
}
}
B b = new B();ITest test = b;
test.Test();A a = b;
a.Test();test = a;
test.Test();
//输出分别为
B test! -----(1)
A test! -----(2)
B test! -----(3)其中(1)和(2)的输出很好理解!但(3)的输出本人去想不明白!
{
void Test();
}class A: ITest
{
public void Test()
{
Console.WriteLine("A test!");
}
}class B : A, ITest
{
public void Paint()
{
Console.WriteLine("B test!");
}
}
B b = new B();ITest test = b;
test.Test();A a = b;
a.Test();test = a;
test.Test();
//输出分别为
B test! -----(1)
A test! -----(2)
B test! -----(3)其中(1)和(2)的输出很好理解!但(3)的输出本人去想不明白!
test.Test(); A a = b;
a.Test(); test = a;
test.Test();
这输出的都是 public void Test()
{
Console.WriteLine("A test!");
}
http://topic.csdn.net/u/20090728/10/c78fdd36-f24c-4aa4-9847-d7af2757eb4a.html