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.
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.
Midhun TpPosted Aug 25, 2016, 11:16 AM
DarilPosted Nov 8, 2021, 11:19 AM
Bikesh SrivastavaPosted Aug 26, 2016, 3:09 AM
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.
"Tapan PatelPosted Aug 25, 2016, 11:09 AM