Why Multiple inheritance is not supported in c#

Posted by Rajesh081725 under C# on 11/30/2012 | Points: 10 | Views : 17173 | Status : [Member] | Replies : 4
can u any one tell me

Why Multiple inheritance is not supported in C# ,given some example

Time is Gold
Thanks & Regards,
Rajesh Kumar,
9962038582.



Responses

Posted by: Kundnani.Rt on: 1/19/2013 [Member] Starter | Points: 25

Up
0
Down
Because it creates problems when design become complex, i.e. in complex designs, it creates multipath inheritance that causes compiler ambiguity.

So, to make it simple C# has provided Interfaces to implement multiple inhertance.

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rama Sagar on: 1/19/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
In C# multiple inheritance has been eliminated to avoid the potential pitfalls of Hybrid inheritance and the ambiguities involved, i.e., when multiple copies of the same object is made available to a derived class from multiple inheritance classes. At that time scope resolution becomes a major issue. Please note that interfaces are merely used as contracts - they are not used for multiple inheritance. Multiple inheritance is NOT supported by C# or Java.

ramasagar

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sourabh07 on: 1/22/2013 [Member] Starter | Points: 25

Up
0
Down
That's Great, Sir...

Ya, It is true that multiple inheritance creates an ambiguity, that's why interfaces are introduced to overcome this drawback....

Interfaces are more useful .....infact one should use interfaces for each class because the contracts allow us to control the use of public methods in to the various class objects.

Also, the whole scenario of WCF is based on the contracts.



Sourabh07

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 1/23/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Refer

http://www.c-sharpcorner.com/UploadFile/cbreakspear/MultipleInheritance11082005004843AM/MultipleInheritance.aspx
http://www.c-sharpcorner.com/uploadfile/b942f9/simulating-multiple-inheritance-in-C-Sharp-part-i/
http://www.c-sharpcorner.com/uploadfile/b942f9/simulating-multiple-inheritance-in-C-Sharp-part-ii/

If this post helps you mark it as answer
Thanks

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response