An interface defines a contract: a class that implements it must provide the specified members. Interface methods and properties must be public. A class can implement multiple interfaces, but it can derive from only one base class. section 2.8
An abstract class is different: it can contain an incomplete implementation, with missing members marked abstract. It cannot be instantiated directly. Choose an interface when the important relationship is the contract a class fulfills, rather than a shared base-class implementation. section 2.8
An interface in a generic parameter
In command-line parsing, IEnumerable<string> specifies an enumerable of strings. IEnumerable is an interface implemented by arrays, lists, and other collections, so the parameter is not tied to just one collection type. section 2.8
Interfaces can also remove a direct dependency on one implementation. A card deck that depends on System.Random for shuffling can instead depend on a randomization interface. The application can then choose an implementation suited to the situation, giving it more control over shuffling. section 6.2.5
Figure 6.3 A class diagram of DeckOfCards with a dependency on an interface to perform randomization along with implementations of that interface
The class diagram shows the deck depending on an interface, with separate implementations supplying randomization. section 6.2.5






