| All Questions ASP.NET CSharp SQL Server WCF HR Interview Questions | |
| Didn't find what you are looking for? Search this site, for frequently asked ASP.NET, C#, SQL Server, WCF and HR Interview Questions | |
Why C# does not support multiple class inheritance?
or
What are the problems of multiple class inheritance?
C# does not support multiple class inheritance because of the diamond problem that is associated, with multiple class inheritance. Let us understand the diamond problem of multiple class inheritance with an example.
![]() |
As shown in the image above:
1. I have 2 classes - ClassB and ClassC
2. Both of these classes inherit from ClassA
3. Now, we have another class, ClassD which inherits from both ClassB and ClassC
So, if a method in ClassD calls a method defined in ClassA and ClassD has not overriden the invoked method. But both ClassB and ClassC have overridden the same method differently. Now, the ambiguity is, from which class does, ClassD inherit the invoked method: ClassB, or ClassC?
In order not to have these problems, C# does not support multiple class inheritance.
| All Questions ASP.NET CSharp SQL Server WCF HR Interview Questions | |
| Didn't find what you are looking for? Search this site, for frequently asked ASP.NET, C#, SQL Server, WCF and HR Interview Questions | |

use virtual inheritence
ReplyDelete