Interfaces

An interface is a contract with the type that inherits and implements the interface. As part of that contract, interfaces are immutable. If the interface changes, it could break the type that inherited the interface. Conversely, the type promises to implement the interface fully.

For example, all vehicles have the same basic behavior: ignition on, ignition off, turn left, turn right, accelerate, and decelerate. A car, truck, bus, and motorcycle are all considered vehicles. As such, they must implement the basic functions of any vehicle. The vehicle interface defines that baseline. The different vehicle types inherit the vehicle interface and implement the behavior specific to that type. A car accelerates differently from a motorcycle. ...

Get Programming Microsoft® Visual C#® 2008: The Language 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.