Interview Question
Qus: Do we have multiple inheritance in .NET? Why?
Multiple inheritance is not supported by .NET using classes and to understand that you need to understand the Diamond problem first:
The Diamond problem is an ambiguity that arises when two classes B and C inherit from Class A and class D inherits from both B and C. If a method in D calls a method defined in A(and does not override the method), and B and C have overridden that method differently, then from which class does it inherit: B or C?
So, the solution is to use interfaces for multiple inheritance.
Answers (2)
The Diamond problem is an ambiguity that arises when two classes B and C inherit from Class A and class D inherits from both B and C. If a method in D calls a method defined in A(and does not override the method), and B and C have overridden that method differently, then from which class does it inherit: B or C?
So, the solution is to use interfaces for multiple inheritance.