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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amira BedhiafiRank #601 · 4K reputationPosted May 27, 2025, 3:03 PM EDT
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.Kiran KumarRank #1,268 · 1.4K reputationPosted May 28, 2025, 5:36 AM EDT
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
Amira BedhiafiRank #601 · 4K reputationPosted May 29, 2025, 8:29 AM EDT
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.