// The Garage delegates all work orders to the ServiceDepartment
// (finding a good mechanic is always a problem...)
static void Main(string[] args)
{
Console.WriteLine("*****Delegates as Parameters *****\n");
// Make the garage.
Garage g = new Garage();
// Make the service department.
ServiceDepartment sd = new ServiceDepartment();
// Wash all dirty cars.
g.ProcessCars(new Car.CarMaintenanceDelegate(sd.WashCar));
// Rotate the tires.
g.ProcessCars(new Car.CarMaintenanceDelegate(sd.RotateTires));
Console.ReadLine();
}
Figure 11-5 shows the current output.
Figure 11-5.
Passing the buck
C H A P T E R 1 1
■
D E L E G AT E S, E V E N T S, A N D L A M B D A S
356
8849CH11.qxd 10/1/07 10:43 AM Page 356
Do'stlaringiz bilan baham: |