Defining Interfaces

To declare an interface, you use the interface keyword rather than class or struct. In the interface body, zero or more members can be specified, without any implementation provided. For example:


All this says is that a type implementing this interface promises to support the disposal operation by providing an implementation for the Dispose method.

Contracts or Not?

Where some people disagree with the idea of interfaces as contracts is that they do not really specify a “complete contract” beyond a series of signatures that are merely a syntactic concern. For example, what’s a type supporting IDisposable supposed to do if ...

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

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