Exemple #1
0
        static void Main()
        {
            CarCollection <Car> VehicleFleet = new CarCollection <Car>();

            VehicleFleet.Add(new Car("Audi A4", 1997));
            VehicleFleet.Add(new Car("Ford Mustang", 1993));
            VehicleFleet.Add(new Car("Seat Leon", 2010));
            PrintCollection(VehicleFleet);

            Console.WriteLine("\nRemoving all elements from the collection");
            VehicleFleet.RemoveAll();
            PrintCollection(VehicleFleet);
            Console.ReadKey();
        }
Exemple #2
0
 public static void PrintCollection(CarCollection <Car> vehicleFleet)
 {
     if (vehicleFleet.ElementsCount != 0)
     {
         for (int i = 0; i < vehicleFleet.ElementsCount; i++)
         {
             Console.WriteLine("car: {0}, production year: {1}", vehicleFleet[i].CarName,
                               vehicleFleet[i].ProductionYear);
         }
         Console.WriteLine("Number of cars: " + vehicleFleet.ElementsCount);
     }
     else
     {
         Console.WriteLine("the collection is empty!");
     }
 }