class BaseClass
{
public void Method1() { Console.WriteLine("Base - Method1"); Method2(); } public virtual void Method2() { Console.WriteLine("Base - Method2"); } }
class DerivedClass : BaseClass
{
public new void Method2() { Console.WriteLine("Derived - Method2"); } }
DerivedClass dc = new DerivedClass();
dc.Method1();
结果为Base - Method1 Base - Method2
请问为什么得到的结果不是Base - Method1 Derived - Method2?new不是会隐藏基类的成员吗?
蛊毒传说
相关分类