Types of Inheritance in C#.NET
Creating a new class from existing class is called as inheritance.
Inheritance with Example
Inheritance can be classified to 5 types.
- Single Inheritance
- Hierarchical Inheritance
- Multi Level Inheritance
- Hybrid Inheritance
- Multiple Inheritance
when a single derived class is created from a single base class then the inheritance is called as single inheritance.
2. Hierarchical Inheritance
when more than one derived class are created from a single base class, then that inheritance is called as hierarchical inheritance.
3. Multi Level Inheritance
when a derived class is created from another derived class, then that inheritance is called as multi level inheritance.
4. Hybrid Inheritance
Any combination of single, hierarchical and multi level inheritances is called as hybrid inheritance.
5. Multiple Inheritance
when a derived class is created from more than one base class then that inheritance is called as multiple inheritance. But multiple inheritance is not supported by .net using classes and can be done using interfaces.
Handling the complexity that causes due to multiple inheritance is very complex. Hence it was not supported in dotnet with class and it can be done with interfaces.
4:03 AM |
Category: |
0
comments
Comments (0)