Overriding Virtual Members

Overriding a virtual member is done by means of the override keyword. When you type the keyword in the Visual Studio IDE, IntelliSense provides a list of members that can be overridden, as shown in Figure 14.11.

Figure 14.11. Use of the override keyword.

image

As soon as we pick a member from the list presented to us, Visual Studio generates a default implementation that does nothing but defer execution to the base class implementation, as shown in Figure 14.12.

Figure 14.12. Default implementation for an overridden method.

Obviously, you’ll usually want to substitute this code for something more meaningful. However, in some ...

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.