It's not quite as simple a question as you might think :)
Interfaces don't derive from object
but you can call the members of object
on them. So you can call ToString()
on an expression which has a compile-time type of IDisposable
, for example.
Coincidentally, I overhead a conversation between Neal Gafter and Eric at NDC discussing exactly this point...
I believe section 4.2.2 of the spec is over simplified, unfortunately. Hopefully Mads and Eric will fix it up for a future release - I'll mail them to make sure they see this question.
I'm also struggling to find anything in the spec to back up the rest of this answer. Section 3.4.5 of the C# 4 spec comes as close as I can find:
The members of an interface are the members declared in the interface and in all base interfaces of the interface. The members in class object
are not, strictly speaking, members of any interface (13.2). However, the members in class object
are available via member lookup in any interface type (7.4).
The conversion from an interface type to object
is covered by section 6.1.6:
The implicit reference conversions are:
- From any reference-type to
object
and dynamic
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…