This content originally appeared on DEV Community and was authored by Sharad Aade
Inheritance
It is a way to pass the properties and functionality of the parent to the child is called as inheritance.
It helps us achieve code re-usability.
NOTE:- Without a constructor, we can not achieve inheritance because with the help of the parent instance, we can access the parent properties and functionalities.
If you do not provide an explicitly constructor, then the compiler provides an implicitly.
Types of inheritance-
- Single
- Multi-level
- Hierarchical
- Hybrid
- Multiple(We can achieve with Interface in C#)
1. Single
In this inheritance, one parent class has only one child class.
2. Multi-level
In this inheritance, the chaining of the parent and child classes occurs.
3. Hierarchical
In this inheritance, one parent class has two or more child classes.
(Simply, Multiple derived classes inherit from a single base class.)
4. Hybrid
This is a combination of two or more types of inheritance.
5. Multiple(We can achieve this with an Interface in C#)
C# does not support multiple inheritance of classes (a class cannot directly inherit from two or more classes). However, it achieves a form of multiple inheritance through interfaces
NOTE:- We will discuss the Interface in another post.
Link:- Coming soon… or check my profile.
This content originally appeared on DEV Community and was authored by Sharad Aade