Possible Duplicate:
Do interfaces derive from System.Object? C# spec says yes, Eric says no, reality says no
It is said all objects in .net inherit from System.Object.
Is that true?
I try to find what object the Ilist interface inherited from on the MSDN, but there’s no mention about its inheritance.
Can anyone tell me something?
Interfaces themselves aren’t objects in a class hierarchy. They are “types” in the sense that they represent an object. But they aren’t concrete classes in and of themselves.
For example, you can’t instantiate an
IList<int>. This wouldn’t compile:However, you can create a
List<int>, which does inherit fromSystem.Object:This instance of
listcan be viewed as lots of different interfaces. For example:And so on. This is because its concrete type,
List<int>, implements multiple interfaces. It doesn’t inherit from them, as they themselves are not concrete types.It seems like where you’re getting lost is in the different between inheritance and interfaces. Some might say that interfaces are “.NET’s answer to multiple inheritance” which can be a fair statement. But there’s a fundamental difference between the two concepts. Think of inheritance as a hierarchy of what an object is:
And so on. Interfaces don’t fit into this hierarchy. Think of an interface, instead, as a contract which an object meets. For example, all
Vehicleobject might implement theIDrivableinterface. Some of them might implement theIFlyableinterface. Some still might implement both (flying cars).