O'Reilly logo

Illustrated C# 2008 by Daniel Solis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 17. Interfaces

What Is an Interface?

An interface is a reference type that represents a set of function members, but does not implement them. Other types—classes or structs—can implement interfaces.

To get a feeling for interfaces, I'll start by showing one that is already defined. The BCL declares an interface called IComparable, the declaration of which is shown in the following code. Notice that the interface body contains the declaration of a single method, CompareTo, which takes a single parameter of type object. Although the method has a name, parameters, and a return type, there is no implementation. Instead, the implementation is replaced by a semicolon.

Figure 17-1 illustrates interface IComparable. The CompareTo method is shown ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required