Is the interface inheriting from System.Object?

  • 2
    these are unrelated concepts - Grundy
  • And what's the difference to you? If your instans will still inherit from Object (if you do not write hellish hacks on a pure IL)? - Anton Komyshan
  • one
    Well, here is the answer to your question . - Anton Komyshan

1 answer 1

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 a IDisposable d; d.(методы_object) surprise why so? But any type derived from any interface will be inherited from Object .. 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