Click here to Skip to main content
15,885,119 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Can anyone describe that how to achieve abstraction in c#.net. I know what is abstract class and all conceptual knowledge..... but dont know, where i am using Abstraction...???
Posted
Comments
[no name] 26-Nov-12 8:23am    
It is a good question if you are a beginner. Writing down the answer.

Well we will start it's theory and then go the labs ;)

One the most fav question of my english teacher was, 'write the abstraction of the story'. We have read the story and then have to write entire stuff in 2-3 lines. So abtraction is 'taking out the important stuff from a huge class and providing a handel to outer world so that they can use it.' If you have drove a car, did you ever saw the 'Gear Box Mechanism'? No, because we have a lever (handel) to access it. So, this was my so called lay man defination.

Practical :

1. An interface is example of Abstraction : It contains signature of methods to be implimented, but have no code. Simmilar for Abstract classes.

2. Getter and setter of property : Inside your getter and setter you fetch and change your internal variables but the outerworld (developer), only knows that he is provide / getting age or name etc of a customer.

3. Delegates : No implimentation only points to functions and events.

4. LINQ : have you used linq ? Tried Where() or any quantifer ? Do you know what happens inside ? It give you an handel to access the inside code.

Improvement of this answer will be highly appriciated.
 
Share this answer
 
Abstraction is a mental process (see Wikipedia[^]) , it has (almost) nothing to do with abstract class (that is a C# language entity).
Abstractions are very useful in OOP (like in many other areas of knowledge), you are encouraged to read a good book on OOP.
 
Share this answer
 
Comments
Sushil Mate 1-Jun-15 1:32am    
just stumbled upon this question from nowhere.. you have written good answers before & this one kind of misleading to OPs. would you like reconsider your answer?
mainly "it has (almost) nothing to do with abstract class (that is a C# language entity)".
If you have conceptual idea of what abstract class is then following links might be helpful to you for achieving the same.

http://msdn.microsoft.com/en-us/library/sf985hc5.aspx[^]

http://www.dotnetperls.com/abstract[^]

All about abstract classes.[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900