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