Hi,
Why Multiple inheritance is not supported by C#.
Thanks ,in advance
Loading
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.
VulpesPosted Aug 17, 2011, 4:17 AM
Jaganathan BantheswaranPosted Aug 17, 2011, 1:02 AM
Basically, it seemed that both the .NET and Java designers did not allow multiple inheritance because they reasoned that adding MI added too much complexity to the languages while providing too little benefit.
Source article here.Priya LingePosted Aug 17, 2011, 1:00 AM
When one or more of the parent classes defines members with same identifier
that time how can we decide which parent to use to handle each method call,
and the operation of class can be then very different than intended.
Example :
Class A
{
Public void FirstFunction()
{
//......
}
}
Class B
{
Public void FirstFunction()
{
//......
}
}
Class C:A,B
{
static void Main()
{
C obj=new C();
obj.FirstFunction();//Here runtime gets confused whether to call FirstFunction() of Class A or B; Ambuguity
}
}
Multiple inheritance is possible using interfaces.
Hope this will help you.
Thanks.