Calling an Overridden Function in the Base Class

Listing 16.5 demonstrated our ability to call an indexer of a base class from a derived class with the base access construct. You can also call a method or a property of a base class from a derived class in a similar fashion. Listing 16.6 gives an example of how a method of a base class method can be called with the base access construct from a derived class and why it sometimes can be useful.

Listing 16.6. CallingOverriddenMethod.cs
 01: using System; 02: 03: class Car 04: { 05: private string brandName; 06: private uint odometer; 07: 08: public Car(string initialBrandName, uint initialOdometer) 09: { 10: brandName = initialBrandName; 11: odometer = initialOdometer; 12: } 13: 14: public Car() ...

Get C# Primer Plus now with O’Reilly online learning.

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