Can we perform multiple inheritence in class
q
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
Manikandan MurugesanRank #300 · 8.4K reputationPosted Sep 3, 2017, 5:41 AM EDT
C# and the .net CLR have not implemented MI because they have not concluded how it would inter-operate between C#, VB.net and the other languages yet, not because "it would make source more complex"
MI is a useful concept, the un-answered questions are ones like:- "What do you do when you have multiple common base classes in the different superclasses?
Perl is the only language I've ever worked with where MI works and works well. .Net may well introduce it one day but not yet, the CLR does already support MI but as I've said, there are no language constructs for it beyond that yet.
Until then you are stuck with Proxy objects and multiple Interfaces instead :(
Consider just using composition instead of trying to simulate Multiple Inheritance. You can use Interfaces to define what classes make up the composition, eg:
ISteerableimplies a property of typeSteeringWheel,IBrakableimplies a property of typeBrakePedal, etc.Once you've done that, you could use the Extension Methods feature added to C# 3.0 to further simplify calling methods on those implied properties, eg:
Hassan Uddin MughalRank #2,508 · 560 reputationPosted Sep 3, 2017, 8:52 PM EDT
Nilesh ShahRank #42 · 34.2K reputationPosted Sep 4, 2017, 6:17 AM EDT
Hamid KhanRank #424 · 5.9K reputationPosted Sep 4, 2017, 10:47 AM EDT