RE: Why multiple Inheritance is not possible in C#?
When we use the Multiple inherutance .. we use more than one class.....ok. Lets one condition class A and class B are base classes and class c is is multiple inherting it ok........and where class c is inheriting a function ......ok it may be possible that this function with same name and same signature can present in both class A and Class B .. That time how the compiler will know ..that which function it should take wherether from class A or class B.So this time Multiple inheritanc won't work .So avoiding this problem we use Interface..... what is interface ... means in interface we just declare a function ...ok 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.
RE: Why multiple Inheritance is not possible in C#?
To avoid name collision. Multiple Inheritence can have many classes and methods , and its quite possible that they can have save name " say a save function in two different classe name can be Save() but implementation can be different". The derived class will have problem accessing the correct function.
Multiple Inheritance is possible in C++, but its not possible in Java, and C#.
what we are read above those are all we know, but as per my knowledge, in C++ to resolve multiple inheritance we are using "this pointer". But in C# there is no pointer concept. In such way, the architectures using the interface concept. To resolving the ambiguity "this pointer" concept used in c++.
Offcourse it not absolutely correct, but its my idea only. If you are agree with my view then follow it, else leave it.
RE: Why multiple Inheritance is not possible in C#?
Hi
Your answer is good but I have doubt, I can call the Method is class as A.fun1(), B.fun1() in derived class C. In that way we can use the multiple inheritance concept in dotnet.
RE: Why multiple Inheritance is not possible in C#?
Multple inheritance is coneceptually wrong. It shouldn't be allowed in any language. Inheritance is the strongest relationship that can be expressed in OO languages. It's used to express IS-A relationship. Aggregation is used to express IS CONSTRUCTED IN TERMS OF. If you're using multiple inheritance in C++ then you're design is wrong and you probably want to use aggregation. On the other hand it's plausible to want to use multiple interfaces. For instance you might have a class wheel and a class engine. You could say that your class car inherits from wheel and from engine but that's wrong. In fact car aggregates wheel and engine because it is built in terms of those classes. If wheel is an interface and engine is an interface then car must inherit both of these interfaces since it must implement the functionaity of wheel and engine .On this basis we can see that multiple inheritance for classes should not be allowed because it promotes mis-use of the strong IS-A relationship. C# enforces the correct concepts whilst C++ allows mis-use. multiple interface inheritance is permissible and C# allows this. It's all to do with properly understanding OO concepts.Try reading Exceptional C++ by Herb Sutter to get a good discussion of the correct and incorrect uses of inheritance.
RE: Why multiple Inheritance is not possible in C#?
Jonathan is right. Absolute Multiple Inheritance is not possible in c# but partially it supports multiple inheritance by the use of Interfaces. As interfaces force a class to implement same type of behaviour (as defined in interface) which classes implements that interface.