Interfaces Overview
The document is archived and information here might be outdated

Interfaces Overview

Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes.

An interface represents a contract, in that a class that implements an interface must implement every aspect of that interface exactly as it is defined.

With interfaces, you can define features as small groups of closely related members. You can develop enhanced implementations for your interfaces without jeopardizing existing code, thus minimizing compatibility problems. You can also add new features at any time by developing additional interfaces and implementations.

Although interface implementations can evolve, interfaces themselves cannot be changed once published. Changes to a published interface may break existing code. If you think of an interface as a contract, it is clear that both sides of the contract have a role to play. The publisher of an interface agrees never to change that interface, and the implementer agrees to implement the interface exactly as it was designed.

Versions of Visual Basic prior to Visual Basic .NET could consume interfaces but not create them directly. Visual Basic .NET allows you to define true interfaces using the Interface statement, and to implement interfaces with an improved version of the Implements keyword.

See Also

Interface Definition | Interface Statement | Implements Keyword | Interface Implementation Examples | When To Use Interfaces | Creating and Implementing an Interface | Walkthrough: Creating and Implementing Interfaces | Inheritance

Show:
© 2016 Microsoft