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.
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 Sep 28, 2012, 4:49 AM
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
Santhosh Kumar JayaramanPosted Sep 28, 2012, 4:19 AM
Sandeep Singh ShekhawatPosted Sep 28, 2012, 3:24 AM
Santhosh Kumar JayaramanPosted Sep 28, 2012, 3:20 AM
Sandeep Singh ShekhawatPosted Sep 28, 2012, 3:14 AM
Suppose I have different methods in both class shape1 and Shape2 then it will support?
Thanks
Sandeep
Santhosh Kumar JayaramanPosted Sep 28, 2012, 3:05 AM
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..
Satyapriya NayakPosted Sep 28, 2012, 3:05 AM
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