示例#1
0
        static void Main(string[] args)
        {
            //ICollection<>
            //IList<>

            CarCollection <Car> cars = new CarCollection <Car>()
            {
                new Car()
                {
                    Name = "Volvo"
                },
                new Car()
                {
                    Name = "BMW"
                },
                new Car()
                {
                    Name = "Toyota"
                },
                new Car()
                {
                    Name = "Lada"
                }
            };

            Console.WriteLine(new string('-', 50));

            Console.WriteLine($"Количество элементов в коллекции = {cars.collection.Length}");

            Console.WriteLine(new string('-', 50));

            foreach (Car item in cars)
            {
                Console.WriteLine(item);
            }

            Console.ReadLine();
        }
示例#2
0
 public CarEnumerator(CarCollection <T> collection)
 {
     this.collection = collection;
     pointer         = -1;
 }