Abstraction in OOPs

Abstraction is one of the principle of object oriented programming . It is the concept of display only the necessary and essential features of an object .You can find the concept of Abstraction in your real world in many instances .

Example for Real world Example : The simple and well known example is steering of the car . if you turn the steering to right the wheels will be moved to right. hence As a driver you will be instructed to use the steering as the essential feature to drive instead of explaining the internal mechanism how the wheels worked .

How to Implement in Your Real time Project?

For the Beginners , it is important to implement oops concept in your code as it indicates the quality of your code . You can implement abstraction in many ways . The best and simple way is using property procedures


public class B{
public void PrintB(){
Print();
}
private int abc;
public int abcd{ //set a value for private member by C# properties.
get{
return abc;
}
set{
abc = value;
}
}
}
public class Program
{

public static void Main()
{
B b = new B();
b.PrintB();
b.abc = 5;
b.abcd = 5;
Console.WriteLine(b.abcd);
}
}

Encapsulation Vs Abstraction 

suggest your points thru comments.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s