Difference between interface and inheritance in c#.
r both same ?.
i want clarity on this topics..could u plz tell me exact difference between them .
Thanks & Regards,
Pavan.
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
Midhun TpRank #388 · 6.5K reputationPosted Aug 25, 2016, 7:16 AM EDT
Tapan PatelRank #614 · 3.9K reputationPosted Aug 25, 2016, 7:09 AM EDT
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Aug 25, 2016, 11:09 PM EDT
Class inheritance represents an "is-a" relationship, e.g., a
Tankis aVehicle. If your situation doesn't at least meet this, choose interface over inheritance.If the proposed base class doesn't provide default implementations for your methods, this would be another reason to choose interface over inheritance.
In C#, you can only inherit from one class but multiple interfaces. This would be yet another reason to choose interface over inheritance.
"Daril148 reputationPosted Nov 8, 2021, 6:19 AM EST