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不是会隐藏基类的成员吗?
- 1 回答
- 0 关注
- 633 浏览
添加回答
举报
0/150
提交
取消