This article will explain you about inheritance by using a suitable example for the fresher's and for the working guy's to clear the OOP's concept.
Introduction
This article will explain you about inheritance by using a suitable example for the fresher's and for the working guy's to clear the OOP's concept. Watch our 500 videos on Azure, WCF, WPF, LINQ, Design Patterns, WWF, Silverlight, UML @ http://www.questpond.com
What is Inheritance?
Inheritance, together with encapsulation and polymorphism, is one of the three primary characteristics (concept) of object-oriented programming Inheritance enables you to create new classes that reuse, extend, and modify the behavior that is defined in other classes The Class whose methods and variables are defined is called super class or base class The Class that inherits methods and variables are defined is called sub class or derived class Sometimes base class known as generalized class and derived class known as specialized class Keyword to declare inheritance is “:” (colon) in visual c#.
Benefits of using Inheritance
Once a behavior (method) or property is defined in a super class(base class),that behavior or property is automatically inherited by all subclasses (derived class). Code reusability increased through inheritance Inheritance provide a clear model structure which is easy to understand without much complexity Using inheritance, classes become grouped together in a hierarchical tree structure Code are easy to manage and divided into parent and child classes
Example of Inheritance

Types of Inheritance in C#: -
- Implementation Inheritance
- Multiple Inheritances (Interface Inheritance)
Implementation Inheritance
One base class (super class) and one derived class (sub class).
Sample Picture:

Interface Inheritance
An interface looks like a class, but has no implementation. It contains definitions of events, indexers, methods and properties. An interface inherited by classes An interface inheritance defined with keyword “interface”. In C# Interface Inheritance also known as multiple inheritances.
Inheritance Tree Structure:

Code Example
"Implementation inheritance code example" and "Interface inheritance code example" attached at the top of this article.