O'Reilly logo

C# Primer Plus by Klaus Michelsen

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

Polymorphism

In general, polymorphism means the ability to have many forms. Before we look closer at its meaning in computer science, we need to make a couple of important observations that are related to the inheritance hierarchy.

An Object of a Descendant Class Has More Than One Type

Consider our chain of derived classes in Figure 16.9 of Chapter 16. In everyday life, most people agree that a racing car is a car, a car is a surface vehicle, and a surface vehicle is a transportation vehicle. However, the contrary is not true, a car is not necessarily a racing car. In computer science and in C#, this is also the case. An object of type SportsCar is therefore also of type Car and of type SurfaceVehicle and of type TransportationVehicle. Consequently, ...

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