Working with Polymorphism

Using virtual methods and the override keyword, you can implement polymorphism, the capability to determine at runtime which type of object is stored in a variable and to call that object's methods correctly. For example, if you derived Menu from a base class named Window and each of these classes had a different virtual version of the Open method, you could put off until runtime which type of object, Window or Menu, to place in a Window variable. If you put a Window object into a Window variable and called its Open method, Window.Open would be called, but if you placed a Menu object into a Window variable (which is legal since Menu is derived from Window) and called its Open method, Menu.Open would be called.

In other ...

Get Microsoft® Visual C#® .NET 2003 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.