What is Abstraction in DotNetFramework
Loading
What is Abstraction in DotNetFramework
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amira BedhiafiPosted May 27, 2025, 7:03 PM
It is the concept of hiding complex implementation details and showing only the essential features of an object.
It allows you to define abstract classes or interfaces that expose only the required behavior, enabling cleaner and more maintainable code.
In C#, this can be achieved using the
abstractkeyword for classes and methods, or through interfaces using theinterfacekeyword.For example, an abstract class
Shapemight define a methodDraw()without specifying how each shape (circle, square...) is drawn, leaving the specifics to the derived classes. This principle supports loose coupling, polymorphism, and code reusability. You can explore more in Microsoft’s official C# Abstraction documentation.Amira BedhiafiPosted May 29, 2025, 12:29 PM
Imagine you have a toy let's say a car for example. Abstraction is like having buttons on the robot that say walk, talk, or dance you just press the button and it works, without needing to know how the toy does it inside.
Encapsulation is like keeping the toy's wires and batteries hidden inside a cover, so no one can mess with them or break it by accident. So, abstraction helps you use the cae easily, and encapsulation keeps its important parts safe and protected.
Kiran KumarPosted May 28, 2025, 9:36 AM
Nice explaining but do we have any major difference with Encapsulation because main feature also hiding the information right so can please differentiate with encapsulation specifications