Monday, March 05, 2012

Why C# not allowing multiple inheritence


1.C# is not allowing the multiple inheritance because of the below reason.
public class A
{
public virtual int m()
{
return 10;
}
}
public class B : A
{
public override int m()
{
return 20;
}
}
public class C : A
{
public override int m()
{
return 30;
}
}
public class D : B, C
{
//If C# supports multiple inheritence.
//then from which class ( B or C) the method will be inherited
//This is where compiler gets confusion.
//that is the reason why C# not supporting multiple inheritence.
public void test()
{
}
}

No comments:

Post a Comment