views:

66

answers:

1

I often encounter in articles which describe abstract class and interface, that C# does not support multiple inheritance but can be achieved using interfaces. I don't agree to that for the following reasons

  1. We always inherit the state and behavior from any class.
  2. Interface does not define the state or behavior.
  3. We cannot inherit anything from an interface but always implement it.

So bottom line is that C# does not support multiple inheritance and interfaces cannot help us achieve multiple inheritance (in fact we can never inherit from an interface).

+2  A: 

No, you can not implement multiple inheritance in C#, period.

You can, however, get some of the benefits of multiple inheritance through interfaces, namely the part where you can add contracts to a class to make it fit other parts of the system, the substitution principle.

But no, you can not get the part where you inherit behavior from multiple base classes.

Lasse V. Karlsen