Inheritance in oops:
In this tutorial you will learn Inheritance,Purpose of Inheritance and sample code. Getting the features of one class to another class is known as inheritance.
The class which is giving features to another class is known as base class or parent class.The class which getting the features from another class is known as derived class or child class.
The actual mean of using inheritance in our application is ‘Code reusability’ and code optimization.
Similarly in Object Oriented Programming,Inheritance is the process of inheriting properties of objects of one class by objects of another class.
In case of inheritance if we create an object of derive class or child class we are able to call
our own method and variable and also we can call base class methods and variable,this is the cause we say that inheritance provide me code reusability.
class Manager //Parent Class or Base Class
public string Mgr_name;
public string departmant()
return "Assistant Manager";
class Employee:Manager //Inheritance betweentwo classes
//Employee is Derive class or child class
static void Main(string args)
Employee emp = new Employee();
emp.Mgr_name = "ManagerName";
//we are able to call base class variable and methods
emp.Emp_name = "EmpName";
emp.Emp_age = 25;
//we are able to call own(derive class) variable and methods
Types of inheritance in oops
1) Single inheritance
2) Multilevel inheritance
3) Hierarchical inheritance
4) Multiple inheritance
5) Hybrid inheritance
In this inheritance, there is only one base class and one derived class.
In this we have many base classes and many derived classes. The classes which are acts as a base class as well as derived class known as intermediate classes.
In this, there is no. of derived classes derived from one base class.
In this, one class derived from multiple base classes. Multiple inheritance is not supported in c# in classes. We can achieve this by interfaces.
The combination of any two inheritances is known as hybrid inheritance.