相关疑难解决方法(0)

如何调用重写的虚方法的"基本实现"?

鉴于以下代码,有没有办法可以调用类A的方法X版本?

class A
{
  virtual void X() { Console.WriteLine("x"); }
}

class B : A
{
  override void X() { Console.WriteLine("y"); }
}

class Program
{
  static void Main()
  {
    A b = new B();
    // Call A.X somehow, not B.X...
  }
Run Code Online (Sandbox Code Playgroud)

c# oop

71
推荐指数
6
解决办法
9万
查看次数

标签 统计

c# ×1

oop ×1