Hi,
Why Multiple inheritance is not supported by C#.
Thanks ,in advance
Why Multiple inheritance is not supported by C#
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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
Priya LingeRank #785 · 2.9K reputationPosted Aug 16, 2011, 9:00 PM EDT
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.
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Aug 16, 2011, 9:02 PM EDT
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.VulpesRank #55 · 29.2K reputationPosted Aug 17, 2011, 12:17 AM EDT