#752 – C# Does Not Support Multiple Inheritance
January 7, 2013 1 Comment
Some other object-oriented languages, like C++ and Python, support multiple inheritance. Multiple inheritance allows a class to inherit data and behavior from more than one parent class.
C#, on the other hand, does not support multiple inheritance. Every class inherits from exactly one class. Multiple inheritance can lead to certain problems in object-oriented languages. (E.g. the “diamond problem“). C# avoids these problems by supporting only single inheritance.
While a class in C# can only inherit from a single base class, it can implement a number of different interfaces.
Default method implementations in interfaces (C# 8.0) effectively allow multiple inheritance of behavior without introducing the diamond problem, as you have to cast the object to the appropriate interface in order to execute any such default method implementation.