An interface is a reference type that represents a set of function members, but does not implement them. Other types—classes or structs—can implement interfaces.
To get a feeling for interfaces, I'll start by showing one that is already defined. The BCL declares an interface called
IComparable, the declaration of which is shown in the following code. Notice that the interface body contains the declaration of a single method,
CompareTo, which takes a single parameter of type
object. Although the method has a name, parameters, and a return type, there is no implementation. Instead, the implementation is replaced by a semicolon.
Figure 17-1 illustrates interface
CompareTo method is shown ...