Tag: 虚方法

即使当前实例是派生类,我们如何从基类中的另一个方法调用虚方法?

即使当前实例是派生类,我们如何从基类中的另一个方法调用虚方法? 我知道我们可以通过使用base.Method2()从Derived类中的方法调用Base类中的Method2,但我想要做的是从Base类中的另一个虚方法调用它。 可能吗? using System; namespace ConsoleApplication1 { class Program { static void Main( string[] args ) { Base b = new Derived( ); b.Method1( ); } } public class Base { public virtual void Method1() { Console.WriteLine(“Method1 in Base class.”); this.Method2( ); // I want this line to always call Method2 in Base class, […]