Example #1
0
 public static bool More18(CharacteristicStudent student)
 {
     if (student.Age >= 18)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #2
0
 public static bool LenghtLastName(CharacteristicStudent student)
 {
     if (student.LastName.Length > 3)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #3
0
 public static bool FirstLetter(CharacteristicStudent student)
 {
     if (student.FirstName.ToLower().Substring(0, 1) == "a")
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #4
0
        private static void Main()
        {
            List <CharacteristicStudent> students = new List <CharacteristicStudent>()
            {
                new CharacteristicStudent()
                {
                    FirstName = "Vlad", LastName = "Bahlai", Age = 18
                },
                new CharacteristicStudent()
                {
                    FirstName = "Andrew", LastName = "Melnik", Age = 19
                },
                new CharacteristicStudent()
                {
                    FirstName = "Vlad", LastName = "Chypys", Age = 20
                },
                new CharacteristicStudent()
                {
                    FirstName = "Michael", LastName = "Yik", Age = 21
                },
                new CharacteristicStudent()
                {
                    FirstName = "Nikolay", LastName = "Kariy", Age = 22
                },
                new CharacteristicStudent()
                {
                    FirstName = "Fedor", LastName = "Bryzgalov", Age = 23
                },
                new CharacteristicStudent()
                {
                    FirstName = "Alexandr", LastName = "Coder", Age = 14
                },
                new CharacteristicStudent()
                {
                    FirstName = "Vitaliy", LastName = "Chypys", Age = 15
                },
                new CharacteristicStudent()
                {
                    FirstName = "Maria", LastName = "Troelsen", Age = 16
                },
                new CharacteristicStudent()
                {
                    FirstName = "Vika", LastName = "Troelsen", Age = 16
                }
            };



            List <CharacteristicStudent> StudentsAge = students.FindStudent((student) => CharacteristicStudent.More18(student));

            Console.WriteLine("Students age more 17 := ");

            foreach (CharacteristicStudent student in StudentsAge)
            {
                Console.WriteLine("FirstName - {0}, LastName - {1}, Age - {2}", student.FirstName, student.LastName, student.Age);
            }

            List <CharacteristicStudent> StudentsFirstName = students.FindStudent((student) => CharacteristicStudent.FirstLetter(student));

            Console.WriteLine("Students with first letter A :=");

            foreach (CharacteristicStudent student in StudentsFirstName)
            {
                Console.WriteLine("FirstName - {0}, LastName - {1}, Age - {2}", student.FirstName, student.LastName, student.Age);
            }

            List <CharacteristicStudent> foundStudentsLastName = students.FindStudent((student) => CharacteristicStudent.LenghtLastName(student));

            Console.WriteLine("Students with last name more then 3 letters :=");
            foreach (CharacteristicStudent student in foundStudentsLastName)
            {
                Console.WriteLine("FirstName - {0}, LastName - {1}, Age - {2}", student.FirstName, student.LastName, student.Age);
            }



            List <CharacteristicStudent> StudentsAndrew = students.FindStudent((student) => student.FirstName == "Andrew");

            Console.WriteLine("Students with first name Andrew :=");

            foreach (CharacteristicStudent student in StudentsAndrew)
            {
                Console.WriteLine("FirstName - {0}, LastName - {1}, Age - {2}", student.FirstName, student.LastName, student.Age);
            }



            List <CharacteristicStudent> StudentsTroelsen = students.FindStudent((student) => student.LastName == "Troelsen");

            Console.WriteLine("Students with last name Troelsen :=");

            foreach (CharacteristicStudent student in StudentsTroelsen)
            {
                Console.WriteLine("FirstName - {0}, LastName - {1}, Age - {2}", student.FirstName, student.LastName, student.Age);
            }

            Console.ReadKey();
        }