March 2022
Intermediate to advanced
864 pages
19h 46m
English
Content preview from C# 10.0 All-in-One For Dummies
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
Start your free trial



Chapter 7
Interfacing with the Interface
IN THIS CHAPTER
Going beyond IS_A and HAS_A
Creating and using interfaces
Unifying class hierarchies with interfaces
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.
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