Interfaces

Interfaces provide a powerful abstraction to component-based development. Interfaces provide a public contract that allows components to work together. Consider an electrical wall outlet to be a receptor of a specific interface. An appliance that provides the proper plug type, the proper interface, can be used in the electrical wall outlet. The wall outlet implements one interface and the appliance implements another. Essentially, the wall outlet states that it can use any device that implements the 110-plug interface. The appliance states that it can make use of any wall outlet that implements the 110-outlet interface.

In more concrete terms, the alarm clock next to your bed implements several interfaces—the Alarm interface, the ...

Get C# and the .NET Framework: The C++ Perspective now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.