static void Main()
        {
            var students       = StudentsDatabase.GetStudentsList();
            var studentsByName = students.Where(p => (p.FirstName.CompareTo(p.LastName) < 0));

            foreach (var student in studentsByName)
            {
                Console.WriteLine(student.FirstName + " " + student.LastName);
            }
        }
Beispiel #2
0
        private static void Main()
        {
            var printGroup = StudentsDatabase.GetStudentsList().Where(p => p.GroupNumber == 2)
                             .OrderBy(p => p.FirstName);

            foreach (var student in printGroup)
            {
                Console.WriteLine("{0} {1} - Group number: {2}", student.FirstName, student.LastName, student.GroupNumber);
            }
        }
        static void Main()
        {
            var students = StudentsDatabase.GetStudentsList();

            var studentsByAge = students.Where(p => (p.Age >= 18 && p.Age <= 24));

            foreach (var student in studentsByAge)
            {
                Console.WriteLine("{0} {1} - {2}", student.FirstName, student.LastName, student.Age);
            }
        }
        private static void Main()
        {
            var students       = StudentsDatabase.GetStudentsList();
            var enrolledByYear = from student in students
                                 where student.FacultyNumber.ToString().EndsWith("14")
                                 select student;

            foreach (var student in enrolledByYear)
            {
                Console.WriteLine(string.Join(", ", student.Marks));
            }
        }
        static void Main()
        {
            var students = StudentsDatabase.GetStudentsList();

            var sortStudents = students
                               .OrderByDescending(student => student.FirstName)
                               .ThenByDescending(student => student.LastName);

            foreach (var student in sortStudents)
            {
                Console.WriteLine("{0} {1}", student.FirstName, student.LastName);
            }
        }
        private static void Main()
        {
            var students = StudentsDatabase.GetStudentsList();

            var filterByPhoneNumber = students.Where(p => p.Phone.StartsWith("02") ||
                                                     p.Phone.StartsWith("+3592") ||
                                                     p.Phone.StartsWith("+359 2"));

            foreach (var student in filterByPhoneNumber)
            {
                Console.WriteLine("{0} {1} - {2}", student.FirstName, student.LastName, student.Phone);
            }
        }
        static void Main()
        {
            var students = StudentsDatabase.GetStudentsList();
            var filterByEmai = students
                .Where(p => p.Email.Substring(p.Email.Length - 6) == "abv.bg");

            foreach (var student in filterByEmai)
            {
                Console.WriteLine("{0} {1} - email: {2}", student.FirstName
                                                        ,student.LastName
                                                        , student.Email);
            }
        }
        static void Main()
        {
            var students          = StudentsDatabase.GetStudentsList();
            var excellentStudents = from student in students
                                    where student.Marks.Contains(6)
                                    select student;

            foreach (var student in excellentStudents)
            {
                Console.WriteLine("{0} {1} - Marks: [{2}]",
                                  student.FirstName,
                                  student.LastName,
                                  string.Join(", ", student.Marks));
            }
        }
Beispiel #9
0
        private static void Main()
        {
            var students     = StudentsDatabase.GetStudentsList();
            var weakStudents = from student in students
                               where student.Marks.Count(p => p == 2) == 2
                               select student;

            foreach (var student in weakStudents)
            {
                Console.WriteLine("{0} {1}, Marks: [{2}]",
                                  student.FirstName,
                                  student.LastName,
                                  string.Join(", ", student.Marks));
            }
        }