O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required