Polymorphism
The final pillar of object-oriented programming is known as polymorphism, from the Greek word that stands for “many shapes.” In fact, when talking about inheritance, we have already seen most of the polymorphic principles illustrated at the level of member declarations. More specifically, the virtual and override keywords are at the heart of the principle of polymorphism. What we haven’t talked about yet is the different uses it allows. So far, we’ve used virtual
and override
to be able to specialize a class:
To use this counter, we could simply write the following:
However, in addition to this, the principle of polymorphism enables ...
Get C# 4.0 Unleashed 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.