Thursday, 25 February 2016

C#.NET ----- INHERITANCE

Inheritance:

Inheritance is a process of acquiring of the properties from one class to another class that is creating a new class by deriving properties from existing class.

Advantage :  
 we can reuse one class methods and variables without creating same methods and variable again and again. By doing like this we decrease length of program very easily.

We are creating a child class by inheriting the parent class properties, and we can also add some  features to child class.

Parent Class :
 The base class which is already created and gives its properties to derived class is known parent class or base class or super class.

Child Class   :  
The derived class which is takes the properties form already exists base class is known as Child class or derived class or sub class.




In OOP System there are five types of Inheritance are available . they are

  1. Single Inheritance
  2. Hierarchical Inheritance
  3. Multi Level Inheritance
  4. Multiple Inheritance
  5. Hybrid Inheritance 

Single Inheritance:
Creating one new class by deriving properties that is methods and variables from single base class.
It is a simple type of inheritance.



Hierarchical Inheritance:
Creating two or more sub classes from single base class is known as Hierarchical Inheritance.



Multi level Inheritance:
Creating a sub class from already derived class is known as Multi Level Inheritance.



Multiple Inheritance:
Creating a new class by deriving from two or more class is known as Multiple inheritance.



Hybrid Inheritance:
It is combination of any two type of Multi level inheritance,Hierarchical inheritance and Multiple Inheritance, It is rare type of inheritance used in practical.


Note: Other OOP languages like C++ support multiple inheritance and hybrid inheritance. But C# and VB.NET doesn‘t support multiple inheritance and hybrid inheritance to avoid some practical problems while developing future GUI applications like windows forms applications, web sites etc.




--------------------------------------------------------------------------------------------------------------------------

2 comments:

  1. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

    c net training in electronic city

    ReplyDelete