Does c# really support multiple inheritance. People say it supports multiple inheritance in the form of interfaces ? But I dont think so
4 Answers
In the literal sense, it does not support multiple inheritance. It can implement multiple interfaces, which offer polymorphic behaviour, so get you some benefits of multiple inheritance. However you get no base behaviour.
If you need the base behaviour a common tactic is for a base class to implement the interfaces and for derived classes to override this implementation where required.
I have yet to run into the need for multiple inheritance, I don't think C# suffers for the lack of it.
4 Comments
In theory of object oriented languages, there are two concepts that are often mixed together when talking about inheritance in C#/Java/etc.
Subtyping means that a single class can be written in a way that it can be casted to (or viewed as) some other simpler type (called supertype). In C# terms, this means that you can pass an object to a method where a parent class or an interface is expected. An object in C# can clearly have multiple supertypes (parent + as many interfaces as you want)
Subclassing means that a type inherits implementation from some other type. In C# this happens when you have a parent class, but not when you're implementing an interface (because you don't inherit any implementation from the interface). So, C# allows you to have only a single superclass (=parent class).
Comments
Implementation over delegation (IOD) is a very simple coding techniques which allows a developers fast implementation of an system interfaces and multiple inheritance in C# (I know:It is not supported :))
Well the whole idea is basically to have a class field of desired type and to expose functionality public properties of the class based on hidden calls to the member field
So if we have something like Class A and Class B are parents of a Class C.An example of that situation could be the case when we would have a user control which should be able to handle and present a list of customers
Because user control and List are bot classes you couldn't do that directly, by inheriting, because there is no support for multiple inheritance in the case of c# (and I'm happy with that because I think multiple inheritance when not properly used very often leads to class explosion anti pattern)
Comments
The language designers decided not to allow multiple inheritance in C#. It has been discussed before.