What is Abstract Class in C#?
Answer:
If we don't want a class to be instantiated, define the class as abstract. An abstract class can have abstract and non abstract classes. If a method is defined as abstract, it must be implemented in derived class. For example, in the classes given below, method DriveType is defined as abstract.
abstract class Car { public Car() { Console.WriteLine("Base Class Car"); } public abstract void DriveType(); } class Ford : Car { public void DriveType() { Console.WriteLine("Right Hand "); } }
Method DriveType get implemented in derived class.