标签:
c#隐藏和重写基类方法的区别
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace interfaceInfo { public class animal { public void action() { Console.WriteLine("eat sleep fuck"); } public virtual void show() { Console.WriteLine("show..."); } } public class dog : animal { public new void action() { Console.WriteLine("new..."); } public override void show() { Console.WriteLine("override"); } } class Program { static void Main(string[] args) { dog d = new dog(); d.action(); //new... d.show(); //override Console.ReadLine(); animal an = new dog(); an.action(); // eat sleep fuck an.show(); // override Console.ReadLine(); } } }
标签:
原文地址:http://www.cnblogs.com/mc67/p/5008370.html