tags:

views:

162

answers:

3

Do you consider .NET to have multiple inheritance? Why?

Yes, I know that by definition is doesn't, but I have had more than one person argue that since you can inherit more than one interface than it does. I know this is a very subjective question (hence the tag), but I was hoping to get some more views on this.

Edit I am not asking if you think it SHOULD have multiple inheritance, and I am also not saying that you inherit interface. What I was trying to get across in my question is that I have heard several people argue otherwise, and I just wanted to get some more opinions on it. I fully expected 99% of the answers to be "No", but like I said I wanted some more input.

+12  A: 

"Interfaces" are not inherited, rather they specify what you have to implement to properly fulfill the interface definition. Inheritance implies a possible change in behavior - parent class defines something, child class extends that.

.NET allows you to have a single class in the list of parents (right side of the colon), therefore supporting single inheritance, but you are free to implement as many interfaces as you wish.

Also I disagree with the "subjective" tag, there is absolutely nothing subjective about the design decision in .NET to allow for single inheritance.

Otávio Décio
There's a reason the VB.NET keywords are 'extends' and 'implements'. +1. =)
J. Steen
Ehr. Inherits. Not extends. =)
J. Steen
You beat me, but damn it, I was going to answer anyway!
Sean Nyman
@Darth - it's always welcome to have various points of view even if they coincide for the most part.
Otávio Décio
This depends on your definition of inheritance.Many considers multiple inheritance to simply mean; an object that can be of several types. And by that definition C# has multiple inheritance.A more traditional definition is that inheritance means you can form new class that's an extension on an already existing class. In which case C# wouldn't support multiple inheritance, since it can only extend 1 existing class, not multiple.
nos
+3  A: 

The designers of .NET (or at least C#) decided not to include multiple inheritance. For you to say it DOES include it, you would have to change the definition of multiple inheritance, at which point you can pretty much say anything includes multiple inheritance.

A: 

Multiple interfaces is not multiple inheritance. Interfaces are not inherited, they are implemented.

The difference is that interfaces only provide a public set of methods and properties that define a contract between the calling code and the implementing class. Inheritance is more extending an existing class or changing the background implementation.

Sean Nyman