Types of Inheritance In C#

 Acquiring (taking) the properties of one class into another is called inheritance. Code reusability is one of the key features of OOPs and it is achieved via inheritance. Using inheritance, one or more classes can derive from an existing class. The existing class is called a base class, and the inherited class is called a derived or inherited class. 




Single inheritance in C#

It is the type of inheritance in which there is one base class and one derived class. 


Hierarchical inheritance in C#

This is the type of inheritance in which there are multiple classes derived from one base class. This type of inheritance is used when there is a requirement of one class feature that is needed in multiple classes.


Multilevel inheritance in C#

When one class is derived from another, this type of inheritance is called multilevel inheritance.


Multiple inheritances using Interfaces

C# does not support multiple inheritances of classes. To overcome this problem, we can use interfaces. We will see more about interfaces in my next article in detail.

No comments:

Post a Comment