Inheritance with an example in C#.NET
Creating a new class from existing class is called as inheritance.
When a new class needs same members as an existing class then instead of creating those members again in new class, the new class can be created from existing class, which is called as inheritance.
Main advantage of inheritance is reusability of the code.
During inheritance, the class that is inherited is called as base class and the class that does the inheritance is called as derived class and every non private member in base class will become the member of derived class.
When a new class needs same members as an existing class then instead of creating those members again in new class, the new class can be created from existing class, which is called as inheritance.
Main advantage of inheritance is reusability of the code.
During inheritance, the class that is inherited is called as base class and the class that does the inheritance is called as derived class and every non private member in base class will become the member of derived class.
Inheritance can be classified to 5 types.
- Single Inheritance
- Hierarchical Inheritance
- Multi Level Inheritance
- Hybrid Inheritance
- Multiple Inheritance
1. Single Inheritance
when a single derived class is created from a single base class then the inheritance is called as single 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.
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. Note: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.
it is very good explanation of Inheritance
ReplyDeletegood sir ji
ReplyDeleteInheritance is a concept of deriving the features from one class to another class. Inheritance leads to Read more
ReplyDeleteCheck this siteTeKslate for indepth C# training.
Go here if you’re looking for information on C# Training.
good example and content of this blogs so easy and understandable ......
ReplyDeleteSir theory is best but plz give its example of inherritance through programming bhi do...:)
ReplyDeleteit's a nice article and very interesting topic because of this inheritance concept only we can achive dynamic binding, loose coupling.
ReplyDeleteTo get more knowledge on inheritance concept
logon this website http://techenoid.com/
An overwhelming web journal I visit this blog, it's unfathomably amazing. Unusually, in this present blog's substance made inspiration driving truth and reasonable. The substance of data is enlightening
ReplyDeleteIELTS Coaching in chennai
German Classes in Chennai
GRE Coaching Classes in Chennai
TOEFL Coaching in Chennai
spoken english classes in chennai | Communication training
An overwhelming web journal I visit this blog, it's unfathomably amazing. Unusually, in this present blog's substance made inspiration driving truth and reasonable. The substance of data is enlightening
ReplyDelete| Certification | Cyber Security Online Training Course|
Ethical Hacking Training Course in Chennai | Certification | Ethical Hacking Online Training Course|
CCNA Training Course in Chennai | Certification | CCNA Online Training Course|
RPA Robotic Process Automation Training Course in Chennai | Certification | RPA Training Course Chennai|
SEO Training in Chennai | Certification | SEO Online Training Course