How a non static method of an abstract class can be called?
Chetan Ranpariya
Select an image from your device to upload
Hi,
If you have sub class version method too, then need to elaborate the design by adding one interface which will hold all of your such methods, like below. This design can apply to any of your sub class by just implementing this interface.
public
{
//Subclass version will be called
ICommon obj = new MyAbstractChild();
obj.MyAbstractMethod();
//Main abstract class version will be called
MyAbstract obj1 = new MyAbstractChild();
obj1.MyAbstractMethod();
}
public new void MyAbstractMethod()
Console.WriteLine("I am abstract child");
public abstract class MyAbstract : ICommon
As per your Q, non static method of an abstract class can call directly like below from sub class
But you should not Hide or Overrride this method in your sub class
MyAbstractMethod();