Polymorphism

Diversity is better than a monoculture. For everybody who believes in diversity, polymorphism might be the right thing. Polymorphism is the art of making one thing appear in many different facets and in many different ways, but what does that mean when talking about object-oriented languages? This section is entirely dedicated to polymorphism and you'll learn about the main benefits of this feature.

Imagine a set of similar instances of an object. The target of this example is to treat all instances the same way and to find the correct method for every single instance. The next example focuses on this approach:

 using System; // parent class ... abstract public class Vehicle { public Vehicle() { } public virtual void Drive() { Console.WriteLine("The ...

Get Mono Kick Start 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.