why multiple inheritance is not possible directly in c#?
why multiple inheritance is not possible directly in c#?
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.
Sanjeeb LenkaPosted Jul 8, 2013, 12:30 PM
When we use the Multiple inherutance,we use more than one
class.Suppose class A and class B are base classes and
class c is is multiple inherting it.it may be possible that
this function with same name and same signature can present
in both class A and Class B .At this time how the compiler
will know which function it should take wherether from
class A or class B.
So Multiple inheritance won't work.
To avoid this problem we use Interface..... it means in
interface we just declare a function and in the derived
class we give the definition as per the requirement...means
function should be abstract ... and in interface all funcion
[method] should abstract
Er SharmaPosted Jan 13, 2015, 6:33 AM
VulpesPosted Jul 9, 2013, 5:44 AM
http://www.artima.com/intv/dotnet.html
Riyaz AkhtarPosted Jul 8, 2013, 11:25 PM
http://blogs.msdn.com/b/csharpfaq/archive/2004/03/07/85562.aspx
Posted Jul 8, 2013, 11:12 PM
Simply saying you are inheriting from your parent. How many parents you can have only one certainly not many, in other words not multiple parents.
This is the reason multiple inheritance is prohibited in C#. In other words C# is well attuned to real world scenario!
C# does provide an alternative to multiple inheritance, known as an interface.
VulpesPosted Jul 8, 2013, 6:59 PM