Why C# does not support Multiple inheritance?
Please give answer in easy language please don't make confuse MI, CLR etc. because i have already read many blog and article for this but didn't clear so I came here with hope to get solid discussion.
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
Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 27, 2012, 11:05 PM EDT
Please refer the below links
http://www.codeproject.com/Articles/10072/Simulated-Multiple-Inheritance-Pattern-for-C
http://www.c-sharpcorner.com/uploadfile/cbreakspear/multipleinheritance11082005004843am/multipleinheritance.aspx
http://kiranpatils.wordpress.com/2008/03/10/why-c-doesn%E2%80%99t-supports-multiple-inheritance/
Thanks
If this post helps you mark it as answer
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Sep 27, 2012, 11:05 PM EDT
I have a class Shape1
It has CalcualteArea method
Class Shape1
{
public void CalculateArea()
{
//
}
}
There is another class shape2 that one also has same method
Class Shape2
{
public void CalculateArea()
{
//
}
}
Now i have a child class Circle, it derives from both SHape1 and shape2;
public class Circle: Shape1,shape2
{
}
Now when i create object for Circle, and call the method, system doesnt know which calculate area method to be called.. Both has same signatures. So compiler will get confuse .thats why multiple inheritances are not allowed.
But there can be multiple interfaces because interfaces dont ve methjod definition..Even both the interfaces have same method, both of them dont ve any implementation and always method in the child class will be executed..
Guess it would be clear..
Sandeep Singh ShekhawatRank #147 · 15.6K reputationPosted Sep 27, 2012, 11:14 PM EDT
Suppose I have different methods in both class shape1 and Shape2 then it will support?
Thanks
Sandeep
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Sep 27, 2012, 11:20 PM EDT
Sandeep Singh ShekhawatRank #147 · 15.6K reputationPosted Sep 27, 2012, 11:24 PM EDT
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Sep 28, 2012, 12:19 AM EDT
VulpesRank #55 · 29.2K reputationPosted Sep 28, 2012, 12:49 AM EDT
As you'll see, the complexity of dealing with it wasn't the only reason - it would also have been difficult to come up a common approach which all .NET languages could live with:
http://www.artima.com/intv/dotnetP.html