override一個C#函數時,如果想調用這個函數在父類的父類中相應的方法,可以將override關鍵字變成new,調用時將Object轉義成父類的父類class A
{
public virtual void Func( )
{
Console.WriteLine( "A" );
}
}
class B:A
{
public new void Func( )
{
Console.WriteLine( "B" );
}
}
class C:B
{
public void Func( )
{
A a =
this as C;
a.Func( );
}
}