static void UsePersonCollection()
        {
            Console.WriteLine("***** Custom People Collection *****\n");
            PeopleCollection myPeople = new PeopleCollection();
            myPeople.AddPerson(new Person("Homer", "Simpson", 40));
            myPeople.AddPerson(new Person("Marge", "Simpson", 38));
            myPeople.AddPerson(new Person("Lisa", "Simpson", 9));
            myPeople.AddPerson(new Person("Bart", "Simpson", 7));
            myPeople.AddPerson(new Person("Maggie", "Simpson", 2));

            foreach (Person p in myPeople)
                Console.WriteLine(p);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("**** Custom Person Collection ****");
            PeopleCollection myPeople = new PeopleCollection();

            myPeople.AddPerson(new Person("Homer", "Simpson", 40));
            myPeople.AddPerson(new Person("Marge", "Simpson", 38));
            myPeople.AddPerson(new Person("Bart", "Simpson", 8));
            myPeople.AddPerson(new Person("Lisa", "Simpson", 7));
            myPeople.AddPerson(new Person("Maggie", "Simpson", 2));

            foreach (Person p in myPeople)
            {
                Console.WriteLine(p);
            }

            Console.ReadLine();
        }