Qus:    Do we have multiple inheritance in .NET? Why?
Oct 12, 2020 14:17 DotNet 2 Answers Views: 251 ANANYA
Prev Next
Answers (2)
PADMAKEECHU Oct 13, 2020 06:48
Answer:   No, .NET supports only single inheritance due to the diamond problem. Also, it would add complexity when used in different languages. However, multiple interfaces can solve the purpose.

PARTH Oct 13, 2020 12:23
Answer:   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.

Post Your Answer
Guest User

Not sure whare to join tuition right for you?

Choose the right one for you.
Get the help of the experts and find a solution that best suits your needs.


Let`s Connect