7.1. What Is Polymorphism?

Polymorphism refers to the capability of two or more objects belonging to different classes to respond to exactly the same method call in different class-specific ways.

As an example, suppose that we instruct three different people—a surgeon, a hair stylist, and an actor—to "cut":

  • The surgeon would begin to make an incision.

  • The hair stylist would begin to cut someone's hair.

  • The actor would abruptly stop acting out the current scene, awaiting directorial guidance.

These three different professionals can be thought of as objects belonging to different professional classes. Each was given the same message—"cut"—but knew the specific details of what this message meant to him or her by virtue of knowing the profession (class) ...

Get Beginning C# 2008 Objects: From Concept to Code 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.