When should I use abstract classes and when should I use interfaces? with considering latest version of C#.NET
Loading
When should I use abstract classes and when should I use interfaces? with considering latest version of C#.NET
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
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Sep 8, 2022, 1:13 PM EDT
Satish Rathore122 reputationPosted Sep 8, 2022, 11:54 AM EDT
1) when you know scope of requirement use interface and when scope may change or extend use abstract class,
2) when you want all method to be public and force client to implement use interface and when you want different access modifier and do not force to implement on inheritance
3) when you use interface then you simply cannot change it in the end. Abstract classes always have extended compatibility and can still add the behavior without breaking the existing code.
Patel134 reputationPosted Sep 8, 2022, 10:57 PM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Sep 8, 2022, 11:50 PM EDT
Vishal YelveRank #178 · 13.6K reputationPosted Sep 9, 2022, 1:53 AM EDT
Alkesh BijarniyaRank #237 · 10.4K reputationPosted Sep 9, 2022, 2:13 AM EDT
Rajeev KumarRank #1,334 · 1.3K reputationPosted Mar 3, 2023, 2:16 AM EST
Hi Anand
Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing common functionality to unrelated classes. If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class.