Exemplo n.º 1
0
 public void AddRange(EmployeeCollection collection)
 {
     for (int i = 0; i < collection.Count; i++)
     {
         this.List.Add(collection[i]);
     }
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Employee emp1 = new Employee {
                Name = "A", Age = 20
            };
            Employee emp2 = new Employee {
                Name = "B", Age = 20
            };
            Employee emp3 = new Employee {
                Name = "C", Age = 20
            };
            Employee emp4 = new Employee {
                Name = "D", Age = 20
            };

            EmployeeCollection collection = new EmployeeCollection();

            collection.Add(emp1);
            collection.Add(emp2);
            collection.Add(emp3);
            collection.Add(emp4);

            collection.Remove(emp4);

            Console.WriteLine("Without using custom enumerator");
            foreach (Employee item in collection)
            {
                Console.WriteLine(item.Name);
            }

            Console.WriteLine("Using custom enumerator");
            foreach (Employee item in collection.GetEmployeeEnumerator())
            {
                Console.WriteLine(item.Name);
            }

            Console.ReadKey();
        }
Exemplo n.º 3
0
 public EmployeeEnumerator(EmployeeCollection _collection)
 {
     collection = _collection;
 }