Abstract class in C#


An Abstract class is a class that provides a common definition to the subclasses and this is the type of class whose object is not created.

Key points of Abstract Classes

  • Abstract classes are declared using the abstract keyword.

  • We cannot create an object of an abstract class.

  • If you want to use it then it must be inherited in a subclass.

  • An Abstract class contains both abstract and non-abstract methods.

  • The methods inside the abstract class can either have an implementation or no implementation.

  • We can inherit two abstract classes; in this case the base class method implementation is optional.

  • Methods inside the abstract class cannot be private.

  • Abstract classes are useful when you need a class for the purpose of inheritance and polymorphism.

  • The purpose of an abstract class is to provide default functionality to its subclasses.

  • When a class contains at least one abstract method, then the class must be declared as an abstract class.

  • It is mandatory to override the abstract method in the derived class.


Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now