.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Articles >> OOPS >> Post New Resource Bookmark and Share   

 Subscribe to Articles

What is Inheritance?

Posted By:Gurunatha Dogi       Posted Date: August 14, 2009    Points: 25    Category: OOPS    URL: http://www.dotnetspark.com  


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).




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 bottom of this article.

 Subscribe to Articles


Further Readings:

Author: Venkat         Company URL: http://www.dotnetspark.com
Posted Date: August 27, 2009

Excellent...very nice explanation on oops concept in .net...

Author: Beata         Company URL: http://www.dotnetspark.com
Posted Date: May 02, 2012

Great article I am a beginner developer so all information explained in this easy way are useful for me. Here I also have found great article:

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend