标签:
abstract class Test { public virtual void Prinf() { Console.WriteLine("这是虚方法"); } } class SubClassA : Test { public override void Prinf() { Console.WriteLine("这是override的新方法"); } } class SubClassB : Test { public new void Prinf() { Console.WriteLine("这是new的新方法"); } } class SubClassC : Test { public new void Prinf() { Console.WriteLine("这是new的新方法"); } }
运行:
Test t1; SubClassB t2; Test t3; t1 = new SubClassA(); t2 = new SubClassB(); t3 = new SubClassC(); t1.Prinf(); t2.Prinf(); t3.Prinf(); Console.Read();
结果如下:
【2016-10-13】【坚持学习】【Day4】【virtual 虚函数】
标签:
原文地址:http://www.cnblogs.com/zscmj/p/5958428.html