interface is invariant, but that does not mean that the interface is no longer evolving. Similar to class inheritance, interfaces can be inherited and developed.
Note: interface inheritance differs from class inheritance. First, class inheritance is not only a description of inheritance, but also an implementation inheritance, while interface inheritance is simply a description of inheritance. That is, a derived class can inherit the method implementation of the base class, and the derived interface inherits only the member method description of the parent interface, not the implementation of the parent interface. Second, class inheritance in C # allows only single inheritance, but interface inheritance allows multiple inheritance, and a sub-interface can have multiple parent interfaces.
Interfaces can inherit from zero or more interfaces. When inheriting from multiple interfaces, use ":" followed by the inherited interface name, separated by "," between multiple interface names. An inherited interface should be accessible, such as inheriting from a private type or an interface of internal type, which is not allowed. Interfaces do not allow you to inherit directly or indirectly from yourself.
Similar to the inheritance of a class, the inheritance of an interface forms a hierarchy between interfaces.
Take a look at the example below.
Program Listing 15-1:
Using System;
Interface icontrol
{
void Paint ();
}
Interface Itextbox:icontrol
{
void SetText (string text);
}
Interface Ilistbox:icontrol
{
void Setitems (string[] items);
}
Interface icombobox:itextbox,ilistbox{}
Inheritance of an interface inherits all the members of the interface, in the example above, the interface ITextBox and IListBox are inherited from the interface IControl, and the paint method of the interface IControl is inherited. Interface IComboBox are inherited from interfaces ITextBox and IListBox, so it should inherit the SetText method of the interface ITextBox and IListBox method, as well as Setitems IControl method.