Interface Types

Although some framework designers disagree with the statement, I (and the C# specification) sincerely think that interfaces denote contracts. In some respects, the concept of an interface is similar to that of an abstract class. First, you cannot create instances of an interface, which therefore can be considered to be “abstract.” Second, the syntax of declaring members on an interface is pretty similar to abstract members on an abstract class. As you will see, this is pretty much where analogies end. Figure 14.19 illustrates the role of interfaces in terms of a contract shared between two parties: the implementer and the consumer.

FIGURE 14.19 Interfaces are contracts between implementers and consumers.

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.