Chapter 7

Interfacing with the Interface

IN THIS CHAPTER

Bullet Going beyond IS_A and HAS_A

Bullet Creating and using interfaces

Bullet Unifying class hierarchies with interfaces

Bullet Managing flexibility via interfaces

A class can contain a reference to another class, which describes the simple HAS_A relationship. One class can extend another class by using inheritance — that's the IS_A relationship. The C# interface implements another, equally important association: the CAN_BE_USED_AS relationship. This chapter introduces C# interfaces and shows some of the numerous ways they increase the power and flexibility of object-oriented programming. Most importantly, you discover how to unify classes with interfaces to produce clearer application code with improved flexibility.

Remember You don’t have to type the source code for this chapter manually. In fact, using the downloadable source is a lot easier. You can find the source for this chapter in the \CSAIO4D2E\BK02\CH07 folder of the downloadable source. See the Introduction ...

Get C# 10.0 All-in-One For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.