© Andrew Troelsen and Philip Japikse 2017

Andrew Troelsen and Philip Japikse, Pro C# 7, https://doi.org/10.1007/978-1-4842-3018-3_6

6. Understanding Inheritance and Polymorphism

Andrew Troelsen and Philip Japikse2

(1)Minneapolis, Minnesota, USA

(2)West Chester, Ohio, USA

Chapter 5 examined the first pillar of OOP: encapsulation. At that time, you learned how to build a single well-defined class type with constructors and various members (fields, properties, methods, constants, and read-only fields). This chapter will focus on the remaining two pillars of OOP: inheritance and polymorphism.

First, you will learn how to build families of related classes using inheritance. As you will see, this form of code reuse allows you to define common functionality ...

Get Pro C# 7: With .NET and .NET Core 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.