using System;
namespace Anytao.net.My_Must_net
{
class Number
{
public static int i = 123;
public void ShowInfo()
{
Console.WriteLine("base class---");
}
public virtual void ShowNumber()
{
Console.WriteLine(i.ToString());
}
}
class IntNumber : Number
{
new public static int i = 456;
public new virtual void ShowInfo()
{
Console.WriteLine("Derived class---");
}
public override void ShowNumber()
{
Console.WriteLine("Base number is {0}", Number.i.ToString());
Console.WriteLine("New number is {0}", i.ToString());
}
}
class Tester
{
public static void Main(string[] args)
{
Number num = new Number();
num.ShowNumber();
IntNumber intNum = new IntNumber();
intNum.ShowNumber();
Number number = new IntNumber();
//究竟调用了谁?
number.ShowInfo();
//究竟调用了谁?
number.ShowNumber();
}
}
}
为什么是这样的结果
求高手指点下
后面三句代码不是很清楚
谢谢高手指点
qq_笑_17