很简短的C#代码,如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 直接调度测试
{
class Program
{
public class Father
{
public void DoWork()
{
Console.WriteLine("Father.DoWork()");
}
public virtual void DoVirtualWork()
{
Console.WriteLine("Father.DoVirtualWork()");
}
}
public class Son : Father
{
public new void DoWork()
{
Console.WriteLine("Son.DoWork()");
}
public override void DoVirtualWork()
{
Console.WriteLine("Son.DoVirtualWork()");
}
public static void DoStaticWork()
{
Console.WriteLine("Son.DoStaticWork()");
}
}
static void Main(string[] args)
{
Father son2 = new Son();
//
son2.DoVirtualWork();
son2.DoWork();
}
}
}
程序的输出结果如下:
Son.DoVirtualWork()
Father.Dowork()
这里就有点迷糊了,哪位大侠给解释下,十万火急啊!!!!!!!!!!!
注:从CLR层面,肤浅的就不要了,谢谢!
森林海
ibeautiful
哈士奇WWW
大话西游666
侃侃无极
慕斯王