O'Reilly logo

C# 2008 Programmer's Reference by Wei-Meng Lee

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 5. Interfaces

When defining a class, you have to provide the implementation for all its methods and properties. However, there are times when you do not want to provide the actual implementation of how a class might work. Rather, you want to describe the functionalities of the class. This set of descriptions is like a contract, dictating what the class will do, the types of parameters needed, and the type of return results. In object-oriented programming, this contract is known as an interface.

An interface defines a class and its members without providing any implementation. When using interfaces in programming, generally three parties are involved:

  • Interface definition — The interface defines the composition of a class, such as methods, properties, and so on. However, the interface does not provide any implementation for any of these members.

  • Implementing class — The class that implements a particular interface provides the implementation for all the members defined in that interface.

  • Clients — Objects that instantiate from the implementing classes are known as the client. The client invokes the methods defined in the interface, whose implementation is provided by the implementing class.

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