几个问题
问题一:
public class A
{
public A(){}
public virtual functionA()
{
Console.WriteLine("I am A");
}
}
public class B:A
{
public B(){}
public functionA()
{
Console.WriteLine("I am B");
}
}
public static class main()
{
A a = new A();
B b = new B();
a.functiona();
b.functiona();
}
输出结果如下:
I am A
I am B
如果把mian方法里面的代码改动一下
public static class main()
{
A a = new A();
A b = new B();
a.functiona();
b.functiona();
}
输出结果如下:
I am A;
I am A;
如果再把class B 改变一下
public class B:A
{
public B(){}
public new functionA()
{
Console.WriteLine("I am B");
}
}
这个时候改变后的main方法输出为
I am A
I am B