locked
Interface Implementation RRS feed

  • Question

  •  

    Hi,

    Today I opened the definition of Excel.ApplicationClass and I observed that it implements two interfaces called application and _application. Interface _application contains lot of members but interface application is empty and only implements interface _application. So the hierarchy is like this;

    interface _application (interface with members in it)
    interface application (empty interface) : _application
    ApplicationClass (class) : _application, application

    So the class ApplicationClass provides definitions to all members in topmost interface _application. My question is that why does this class need to implement the interface _application if it is already implemented by interface application?

    Thanks in advance for all the answers by you.

    Friday, October 12, 2007 7:07 AM

Answers

  • It doesn't really need to do that, but that's how the C# compiler writes to the compiled assembly. You can try it youself with a simplified hierarchy

     

    interface IFoo {}
    interface IBar : IFoo {}
    class Bar : IBar {}

     

    If you compile that code and open in Ildasm or similar tool you'll see that Bar lists both IFoo and IBar as impemented interfaces. It's just how things are stored in metadata.

    Friday, October 12, 2007 9:18 AM

All replies

  • It doesn't really need to do that, but that's how the C# compiler writes to the compiled assembly. You can try it youself with a simplified hierarchy

     

    interface IFoo {}
    interface IBar : IFoo {}
    class Bar : IBar {}

     

    If you compile that code and open in Ildasm or similar tool you'll see that Bar lists both IFoo and IBar as impemented interfaces. It's just how things are stored in metadata.

    Friday, October 12, 2007 9:18 AM
  • I think you are right. Thanks Mattias!

     

    Thursday, October 18, 2007 8:59 AM