Tuesday, April 23, 2019

Why C# Not support multiple inheritance

Ambiguity issue that's why c# not support multiple inheritance.

   Example:

  1. Assume that class A is having a method fun(). class B and class C derives from class A.
  2. And both the classes B and C, overrides method fun().
  3. Now assume that class D inherits both class B, and C. (just Assumption)
  4. Create object for class D.
  5. D d = new D();
  6. and try to access d.fun(); => will it call class B's fun() or class C's fun()?
This is the ambiguity existing in diamond problem.