Is it possible to call method of an Abstract class in derived class or any other class. My code is below, I want to call Abstr’s Describe() method in Program’s Main method.
Is it possible? if answer is yes how?
class Program
{
public void Main()
{
//I want to call the Describe() method here, how do i do that
Console.ReadLine();
}
}
public abstract class Abstr
{
public void Describe()
{
//do something
}
}
Since your method is not static, you need to initialize a variable from that abstract class and call that method from it. To do that you may inherit the abstract class by concreate class and then call that method. Note that the abstract class can’t be initialized throw a constructor like
Abstr abstr = new Abstr();is not valid. So: