aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

C# - Difference between Instantiation and Inheriting (Inheritance) a Class

May 12, 2016

Here I will explain difference between instantiation and inheriting (inheritance) a class in c#, with example or instantiation vs inheritance in or how to instantiate and inherit a class in using c#, with example. In c# or instantiation means declaring object for class and inheritance means acquiring properties from base class.



Inheritance means it’s a kind of relation between two classes like parent and child. In inheritance child class will acquire all properties from parent class like methods, events, nested types of parent class, operators and fields.

Example of using Inheritance

Following is the simple example of defining inheritance in classes.

// Parent Class
class parent {
// your code
// Child Class
class child : parent {
// child class will inherit all properties from parent class

Instantiation means defining or creating new object for class to access all properties like methods, operators, fields, etc. from class.

Example if Instantiation

Following is the example of defining instantiation in application.

class sampleclass {
// your code
class Program
static void Main()
// Instantiating sampleclass
sampleclass sobj = new sampleclass();

If you observe above syntax we created new object by instantiating sampleclass class. By using new object sobj we can access all the methods and properties from sampleclass class.

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


DGanapathi said...

Hi Suresh,

You have given definitions for instantiation and inheritance, using both ways can access all properties. What is the exact difference?

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.