C# enables you to create abstract classes that are used to provide partial class implementation of an interface. You can complete implementation by using the derived classes. Abstract classes contain abstract methods, which can be implemented by the derived class. Polymorphism can be implemented by using abstract classes and virtual functions. When you create derived classes, you provide more specialized functionality; polymorphism enables you to treat the new objects as general objects.
The following code is an example of the declaration of an abstract class:
Abstract class ExampleAbstract
// This is an abstract class
Static Void Main (String args)
ExampleAbstract obj = new ExampleAbstract ();
//abstract class cannot be instantiated
NOTE: - abstract class is created by using the abstract keyword. There are certain rules governing the use of an abstract class.
The rules are:
• Cannot create an instance of an abstract class.
• Cannot declare an abstract method outside an abstract class.
• Cannot be declared sealed.