What Is Inheritance ?

Inheritance is a fundamental feature of an Object-Oriented programming. It is the process of creating a new Class, called the Derived Class, from the existing class, called the Base Class. Inheritance is a very elegant way to reuse and modify the data and functionality that has already been defined in the Base Class, also you can add new data and functionality to the Derived Class. Since the Derived Class inherits all properties of the Base Class, the Derived Class has a larger set of properties than the Base Class. However, the Derived Class may override some or all the properties of the Base Class.

Object-oriented programming concepts: Inheritance  c# vb.net

Inheritance and the .NET Framework

The Inheritance has many advantages, the most important of them being the reusability of code. Rather than developing new Objects from scratch, new code can be based on the work of other developers, adding only the new features that are needed. The reuse of existing classes saves time and effort. When you create a class to derive from another class, the inherited class implicitly gains all the data and functionality of the base class, except for its constructors and destructors.

What Is Inheritance in .Net Framework C# , VB.Net

From the above example, Cars and Trucks have certain common properties; all have engine, wheels, horns etc. Thus they can be grouped under a Class called Vehicles. Apart from sharing these common features, each Derived Class has its own particular features - Cars use petrol while Trucks use diesel.

Multiple inheritance in .Net Framework

Multiple inheritance in  C# , VB.Net
Multiple inheritances allows programmers to create classes that combine aspects of multiple classes and their corresponding hierarchies. In .Net Framework, the classes are only allowed to inherit from a single parent class, which is called single inheritance. More about.... Why in .NET multiple inheritance is not allowed

However, inheritance may be implemented in different combinations in Object-Oriented Programming languages as illustrated in figure and they include:

  1. Single Inheritance
  2. Multi Level Inheritance
  3. Hierarchical Inheritance
  4. Hybrid Inheritance
  5. Multipath inheritance
  6. Multiple Inheritance
More about.... Different Types of Inheritance