一个很基础的问题,大家说说看法
周公
博客专家认证 2006-10-31 10:11:11 using System;
namespace VirtualDemo
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
Son son=new Son();
Father father=son;
father.MyFun();
son.MyFun();
father.MyGun();
son.MyGun();
Console.ReadLine();
}
}
public class Father
{
public void MyFun()
{
Console.WriteLine("Father.MyFun()");
}
public virtual void MyGun()
{
Console.WriteLine("Father.MyGun()");
}
}
public class Son:Father
{
public new void MyFun()
{
Console.WriteLine("Son.MyFun()");
}
public override void MyGun()
{
Console.WriteLine("Son.MyGun()");
}
}
}
大家看看最后是什么结果,说说你的理由。