C# does not support multiple class inheritance. This is becaues of diamond problem which is associated with multiple class inheritance. For example I am having two classes namely class2 and class3 and these two classes are inherited from class1. Now we have another class namely class4 which is inherited from both class2 and class3. If the method in class4 calls a method in class1 and class 4 has not overridden the invoked method. Both class2 and clas3 has overriden the same methos differently. So there occurs the ambiguity problem wile invoking the methods. In order to solve this plobelm C# does not support multiple class inheritance.
Interviews22 answers
Why multiple inheritance is not possible in c#
22 Answers
satheesh dPosted Nov 12, 2021, 5:55 AM EST
http://www.c-sharpcorner.com/article/diamond-problem-in-c-sharp/
Iqrar AliPosted Dec 13, 2016, 6:57 AM EST
Due to Diamond problem....
atul gopnarPosted Dec 25, 2015, 10:01 PM EST
Multiple inheritance does not get implemented in C# because of Diamond drawback.If it is required to implement multiple inheritance in C# then we use at least one Interface as base class.
Sandeep KumarPosted Dec 21, 2015, 3:27 AM EST
Multiple inheritance is possible in c# while we will use atleast one base class as interface .
Sandeep KumarPosted Dec 18, 2015, 9:23 AM EST
ambiguity issue....
Class A
{
Public void show ()
{
console.writeline("Show from class A");
}
}
Class B
{
Public void show ()
{
console.writeline("show method from class b");
}
}
Class C: class A, class B
{
// which method call here.....
//class A have a show method and class b have also same method so ambiguity problem is here
};
Mahesh GawhanePosted Dec 3, 2015, 12:20 AM EST
This is Cause by diamond Shape problems of two classes If two classes B and C inherit from 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 it), and B and C have overridden that method differently, then via which class does it inherit: B, or C? So., multiple inheritance is not possible in C#. that is called Diamond Problem. But., in C# we can solve the Diamond problem with the help of interfaces in some cases.
Santosh KumarPosted Nov 27, 2015, 1:52 AM EST
This is Cause by diamond Shape problems of two classes If two classes B and C inherit from 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 it), and B and C have overridden that method differently, then via which class does it inherit: B, or C? So., multiple inheritance is not possible in C#. that is called Diamond Problem. But., in C# we can solve the Diamond problem with the help of interfaces in some cases.
Santosh KumarPosted Nov 27, 2015, 1:52 AM EST
Yes, it is due to the diamond problem.
The diamond problem is an ambiguity that arises when two classes B and C inherit from 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 it), and B and C have overridden that method differently, then via which class does it inherit: B, or C?
Dhanik SahniPosted Nov 16, 2015, 7:33 PM EST
Yes, due to diamond problem.
The diamond problem is an ambiguity that arises when two classes B and C inherit from 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 it), and B and C have overridden that method differently, then via which class does it inherit: B, or C?
Dhanik SahniPosted Nov 16, 2015, 7:32 PM EST
It causes the ambiguity error in C#.
Sreekanth ReddyPosted Nov 2, 2015, 6:52 AM EST
It causes the ambiguity error in C#.
Sreekanth ReddyPosted Nov 2, 2015, 6:52 AM EST
Simply, it will increase the complexity (the developer may difficult to find which method is from which class).
Francis SusaimichaelPosted Oct 26, 2015, 3:23 AM EDT
Because when two classes B and C inherit from 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 it), and B and C have overridden that method differently, then via which class does it inherit: B, or C?
So., multiple inheritance is not possible in C#. that is called Diamond Problem.
But.,
in C# we can solve the Diamond problem with the help of
interfaces in some cases.
Ashok ReddyPosted Oct 7, 2015, 11:06 PM EDT
Due To Diamond Problem...
Bhushan BhasmePosted Oct 4, 2015, 7:44 PM EDT
Due to diamond problem.
Sujeet SumanPosted Sep 1, 2015, 9:19 PM EDT
due to the diamond problem.
Pankaj Kumar ChoudharyPosted Aug 26, 2015, 9:14 AM EDT
C# compiler is designed not to support multiple inheritence because it causes ambiguity of methods from different base class.
Sanjukta PearlPosted Aug 17, 2015, 4:06 AM EDT
If multiple inheritance would have allowed in the C#, there would be a problem so called "Diamond Problem". Diamond problem occurs when same method exist in two or more base classes. Thus the child class would end up inheriting duplicate methods.
Dimple SharmaPosted Aug 10, 2015, 6:33 AM EDT
Multiple inheritance is not possible beacuse Multiple inheritance Suffer From Ambugity Problem,that means there can be chances that same method present in both the call.
Swapnil MachePosted Aug 7, 2015, 12:59 AM EDT
http://net-informations.com/faq/general/inheritance.htm
Munesh SharmaPosted Aug 4, 2015, 10:06 PM EDT
Basically it is due to Diamond Problem.
example expalined below:
public class A
{
public virtual void A_Method()
{
Console.WriteLine("Class A Method");
}
}
public class B:A
{
public override void A_Method()
{
Console.WriteLine("Class B Method");
}
}
public class C:A
{
public override void A_Method()
{
Console.WriteLine("Class C Method");
}
}
public class D:B,C // If Multiple inheritence is possible in C# then
{
public override void A_Method()
{
Console.WriteLine("Class C Method");
}
}
public static void main()
{
D objD = new D();
objD.A_Method();// Making object of class D and calling overloaded method A_method will confuse the compiler which class method to call as both inherited class methods has been overloaded.
}
It is called Diamond problem because of the structure it makes while inheriting the classes as below:
Class A(Base Class)
Class B(Inherits A) Class C(Inherits A)
Class D(Inherits B, C)
public class D : IA,IB // Multiple interfaces can be implemented but it will show only one methhods after inheriting for implementation
{
public void Show()
{
throw new NotImplementedException();
}
}
interface IA
{
void Show();
}
interface IB
{
void Show();
}
Rajesh SinghPosted Jul 9, 2015, 2:20 AM EDT














