Overriding Virtual Methods

In this chapter's first example, we defined the Open method in the derived Menu class with the new keyword:

					public new void Open()

The new keyword hides an inherited member with the same signature, and you use it when you are redefining a base class method into something entirely new. But here, Open isn't entirely new. In this case, we're just customizing it for the Menu class. Logically, this method does the same thing for the Menu class as it did for the Window class. For that reason, we should really be overriding the Open method, not specifying that we're redefining it entirely. Overriding it replaces it much as new does, but if you override a method, you're indicating ...

Get Microsoft® Visual C#® .NET 2003 Kick Start now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.