Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            /*Now that you have a strongly typed PersonCollection class, you can use it in your code!
             * Let's create an instance of PersonsCollection and add two Person objects. */
            PersonCollection persons = new PersonCollection();

            persons.Add(new Person()
            {
                Id        = 1,
                FirstName = "Luis Felipe",
                LastName  = "Oliveira"
            });
            persons.Add(new Person()
            {
                Id        = 2,
                FirstName = "Fulaninho",
                LastName  = "da Silva"
            });
            /*Now we can iterave over persons collection using a foreach statement*/
            foreach (Person person in persons)
            {
                Console.WriteLine(string.Format("Id {0}, First Name {1}, Last Name {2}", person.Id.ToString(), person.FirstName, person.LastName));
            }
        }
 public PersonEnumerator(PersonCollection personCollection)
 {
     _personCollection = personCollection;
     _nIndex           = -1;
 }