如何在不继承类的情况下调用抽象类中的方法?

问题描述:

如何在不继承类的情况下调用抽象类中的方法?

How do you invoke a method in a abstract class without inheriting the class?

不,你不能!!

C#中的抽象类和方法 [ ^ ]
No, you can't!!
Abstract classes and methods in C#[^]


我们只能调用抽象类的静态方法而不对其进行子类化。
We can only invoke static methods of an abstract class without sub classing it.


你可以通过为你的方法使用static modifier来调用它。



ex:

摘要A

{

public void G()

{

//代码

}



}



然后你可以这样称呼:

AG();
You can invoke it by using static modifier for your method

ex:
abstract A
{
public void G()
{
// code
}

}

then you can call it like so :
A.G();