Can we perform multiple inheritence in class
q
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.
Hamid KhanPosted Sep 4, 2017, 2:47 PM
Nilesh ShahPosted Sep 4, 2017, 10:17 AM
Hassan Uddin MughalPosted Sep 4, 2017, 12:52 AM
Manikandan MurugesanPosted Sep 3, 2017, 9:41 AM
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: