Introducing Polymorphism

Polymorphism is another key concept in the object-oriented programming. As its name implies, polymorphism enables an object to assume different forms. In .NET development, it basically means that you can treat an object as another one, due to the implementation of common members. A first form of polymorphism is when you assign base classes with derived classes. For example, both Contact and Customer classes are derived of the Person class. Now consider the following code:

image

The new instance of the Person class receives an assignment from an instance of the Contact class. This is always possible because Person is the parent ...

Get Visual Basic® 2010 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.