Is the interface inheriting from System.Object?
1 answer
Not.
The documentation states:
Interfaces do not contain implementation of methods.
If the interface somehow inherited from System.Object , it would inherit the implementation of its methods (for example, ToString() ), which contradicts the documentation.
In fact, in C #, interfaces are not considered classes. For example, a class can inherit only one class, but at the same time implement any number of interfaces.
- Look, the question is caused by the fact that you can write
IDisposable d; d.(методы_object)IDisposable d; d.(методы_object).. what causes aIDisposable d; d.(методы_object)surprise why so? But any type derived from any interface will be inherited fromObject.. maybe the author did not fully understand it :) - Anton Komyshan - @AntonKomyshan: I think that the possibility of such a call is due to the implicit conversion of any reference type to
object(mentioned in the answer to which the link was given in the comments to the question). - VladD - @AntonKomyshan in general, the interface is quite so-so
тип. An open type, along with abstract classes and generalizations. But if you think about how types are arranged in the CLR and where the type will have a link to the interface (on its meta, title and method table), it becomes not so simple. - Artyom Okonechnikov - "implicit conversion of any reference type into object" - yes, yes, I'm also talking about this) at first glance on .net - this is simply not obvious: from where the studio issues object'a methods on the type declared as an interface. - Anton Komyshan
- one@ParanoidPanda: I don’t know about such methods, I think not. - VladD
|