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 O’Reilly online learning.

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