且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#中:如何调用基类的静态方法从派生类的静态方法?

更新时间:2022-04-23 22:31:45

静态方法基本上是从面向对象的概念,回退的方法。因此,他们不是在继承层次结构非常灵活,它不可能直接做这样的事情。

static methods are basically a method to fallback from object oriented concepts. As a consequence, they are not very flexible in inheritance hierarchies and it's not possible to do such a thing directly.

我能想到的最接近的是一个使用指令

The closest thing I can think of is a using directive.

using mybaseclass = Namespace.BaseClass;

class MyClass : mybaseclass {

  static void MyMethod() {  mybaseclass.BaseStaticMethod();  }

}