In this article we will discuss about OOPs concept in .Net. Mainly there are 3 things in OOPs concept.
Inheritance is one of the key feature of oops concept and C# supports inheritance. Inheritance is a process of deriving the new class from already existing class. It allows you to reuse existing code.
A color (:) symbol is used for inheritance like below:
class ChildClass: ParentClass
Note: In .Net every class is inherit from the System.object class
There are different types of inheritance available in C#.Net like below:
– Single Inheritance
When a single derived class is created from a single base class then the inheritance is called as single inheritance.
– Hierarchical Inheritance
When more than one derived class are created from a single base class, then that inheritance is called as hierarchical inheritance.
– Multi Level Inheritance
When a derived class is created from another derived class, then that inheritance is called as multi level inheritance.
– Hybrid Inheritance
Any combination of single, hierarchical and multi level inheritances is called as hybrid inheritance.
– Multiple Inheritance
When a derived class is created from more than one base class then that inheritance is called as multiple inheritance. But multiple inheritance is not supported by .net using classes and can be done using interfaces.
Abstraction is a process of hiding the implementation details and displaying the essential features.
For Abstraction .net provides different access specifiers like below:
Public: Accessible outside the class through object reference.
Private: Accessible inside the class only through member functions.
Protected: Just like private but Accessible in derived classes also through member functions.
Internal: Visible inside the assembly. Accessible through objects.
Protected Internal: Visible inside the assembly through objects and in derived classes outside the assembly through member functions.
Polymorphism means having more than one form. In C#.Net Overloading and overriding are used to implement polymorphism.
Polymorphism is classified into compile time polymorphism or early binding or static binding and Runtime polymorphism or late binding or dynamic binding.
Compile time Polymorphism or Early Binding:
The polymorphism in which compiler identifies which polymorphic form it has to execute at compile time it self is called as compile time polymorphism or early binding.
Runtime Polymorphism or Late Binding:
The polymorphism in which compiler identifies which polymorphic form to execute at runtime but not at compile time is called as runtime polymorphism or late binding.
public int Sum (int X, int Y)
return X + Y;
public float Sum(int X, float Y)
return X + Y;
Here Sum method has been overloaded.
public virtual string Hell0()
return “Hello !!!”;
class DerivedClass : BaseClass
public override string Hell0()
return “Hello !!! Welcome to AspDotNetHelp.com”;
SharePoint Online FREE Training
JOIN a FREE SharePoint Video Course (3 Part Video Series)