What is Abstraction in C#.net

By | November 17, 2017

What is Abstraction in C#.net

  • Abstraction refers to the act of representing essential features without including the background details or explanations.
  • Abstraction defines way to hide your data and members from outside world.
  • This is achieved by means of access specifies.
  • e.g.: Interface
  • Abstraction is used to create a common set of methods that might have different specific implementations by subclasses.

For Example:

Lets consider the example of String class. If the type is of the String then it will definitely support the operations like Concat, IndexOf, Substring, etc. In this case, the operations supported by the entity depend on its type. This is known as abstractions.

Let’s look below figure you will get better idea on what Abstraction means,

Abstraction in C#.Net

Abstraction in C#.Net

 

In Fig A: Type Name is of string type, so it will support only string related function’s only like concat, contains, clone, substring, lenght etc.

In Fig B: Type Roll Num is of Int type, so it will support only int related function’s only.

So operations supported by the entity depend on its type. Means showing only essential features is called asĀ Abstraction.

Advantages:

  • Hinding Implmentation Detail
  • Extensiblity
  • Component Reuse

Go to Home page of OOP or C#.net interview questions

Leave a Reply

Your email address will not be published. Required fields are marked *