This must be either discussed or I’m being extremely stupid. There are plenty of similar threads as to why C# doesnt have MI, I have gone thru most. But I’m curious to know if C# isn’t already supporting it implicitly.
Since every type in .NET derive from System.Object I can write a class as
Person : object { }
Now if I have
Employee : Person { }
Isn’t it really
Employee : object, Person { }
1) Isn’t Employee class already inheriting from two classes?
All the problems of multiple inheritance exists here too right? Lets say I have this:
Person : object
{
new public Type GetType()
{
return null;
}
}
Employee : object, Person
{
}
2) Now if I call Employee.GetType() should it call Person.GetType() or object.GetType()? The confusion exists right. I feel isnt C# magically giving some sort of inheritance precedence for object class as its already in many languages in case of MI?
You’re misunderstanding inheritance.
EmployeeinheritsPerson, only.PersoninheritsObject.EmployeeinheritsObjectindirectly, throughPerson.Because
Personstands betweenEmployeeandObject, there are no MI issues.