Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //Create 4 Person objects
            Person p1 = new Person() { Name = "John", Age = 41 };
            Person p2 = new Person() { Name = "Jane", Age = 69 };
            Person p3 = new Person() { Name = "Jake", Age = 12 };
            Person p4 = new Person() { Name = "Jessie", Age = 25 };

            //Create a list of Person objects and fill it
            List<Person> people = new List<Person>() { p1, p2, p3, p4 };
            DisplayPeople("Children:", people, IsChild);
            DisplayPeople("Adults:", people, IsAdult);
            DisplayPeople("Seniors:", people, IsSenior);

            Console.Read();
        }
Exemplo n.º 2
0
 //==========FILTERS===================
 static bool IsChild(Person p)
 {
     return p.Age <= 18;
 }
Exemplo n.º 3
0
 static bool IsSenior(Person p)
 {
     return p.Age >= 65;
 }
Exemplo n.º 4
0
 static bool IsAdult(Person p)
 {
     return p.Age >= 18;
 }