abstract Methods, Properties, Indexers, and Classes

The Car class in Listing 16.3 of Chapter 16 contained a definition (shown next) for the MoveForward method that added 1 to the odometer variable.

19:     public virtual void MoveForward()
20:     {
21:         Console.Write("Moving forward... ");
22:         odometer += 1;
23:         Console.WriteLine("Odometer reading: { 0} ", odometer);
24:     }

However, as noted in the same section, MoveForward could mean anything in the generic Car class for which it was defined. The implementation of MoveForward in the Car class was merely meant to be a dummy implementation waiting to be overridden in the FamilyCar, SportsCar, and RacingCar classes where we had a better idea of how to implement it (FamilyCar is slow, SportsCar is medium ...

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.