2
Reply

Why multiple Inheritance not work in C sharp?

Pradeep

Pradeep

15y
11.5k
0
Reply

    Multiple inheritance is not supported in C# through classes becauseClass P1{public void func1(){.....;}}Class P2{public void func1(){....;}}Class P3:P1,P2{static void Main(){P3 obj=new P3();P3.func1();//Here runtime gets confused whether to call func1() of ClassP1 orP2; Ambuguity}}Hence Multiple inheritance is possible using interfaces

    When we use the Multiple inherutance we use more than one class. Lets one condition class A and class B are base classes and class c is is multiple inherting it.And where class c is inheriting a function .It may be possible that this function with same name and same signature can present in both class A and Class B . That time how the compiler will know that which function it should take wherether from class A or class B.So Multiple inheritance show's an error.