It is possible to let one interface be a descendent from another interface:
IChildInterface will have two methods: foo and bar. Any class implementing this interface will therefore need to implement both interfaces:
Note that when a class declares a child interface, it can be assigned to a variable with the child interface. Given the above declarations, the following will compile:
But this does not imply that it automatically also is assignment compatible with a variable with the type of parent interface. The following will not compile:
To make this compile, it is necessary to declare the class as:
The reason for this is that although the class actually implements the methods of IParentInterface, the compiler checks only actually declared interfaces when checking assignment compatibility: all declared interfaces are put in a table and only the contents of this table is checked.
The same check is performed at runtime: the compiler generates a table of all interfaces a class declares, and this table is checked at runtime. That means that although the following will compile if only IChildInterface is declared:
it will still fail with a run-time error: