コード例 #1
0
        static void Main()
        {
            Random rand = new Random();
            Student[] students = new Student[10];
            string[] firstNames = new string[] { "Niki", "Doncho", "Pesho", "Maria", "Stamat", "Ivan", "Ivo", "Gosho", "Evlogi", "Svetlin" };
            string[] lastNames = new string[] { "Kostov", "Minkov", "Peshev", "Ivanov", "Stamatov", "Popov", "Kenov", "Goshev", "Hristov", "Nakov" };

            for (int i = 0; i < students.Length; i++)
            {
                string firstName = firstNames[rand.Next(0, 10)];
                string lastName = lastNames[rand.Next(0, 10)];
                Student student = new Student(firstName, lastName);
                for (int j = 0; j < 5; j++)
                {
                    student.Marks.Add(rand.Next(3, 7));
                }
                students[i] = student;
            }

            var excellentStudents = students.Where(st => st.Marks.Contains(6)).Select(st => new { FullName = st.FirstName + " " + st.LastName, st.Marks });

            foreach (var st in excellentStudents)
            {
                Console.WriteLine("{0}, marks --> {1}", st.FullName, string.Join(",", st.Marks));
            }
        }
コード例 #2
0
        static void Main()
        {
            Random rand = new Random();
            Student[] students = new Student[10];
            string[] firstNames = new string[] { "Niki", "Doncho", "Pesho", "Maria", "Stamat", "Ivan", "Ivo", "Gosho", "Evlogi", "Svetlin" };
            string[] lastNames = new string[] { "Kostov", "Minkov", "Peshev", "Ivanov", "Stamatov", "Popov", "Kenov", "Goshev", "Hristov", "Nakov" };
            for (int i = 0; i < students.Length; i++)
            {
                string firstName = firstNames[rand.Next(0, 10)];
                string lastName = lastNames[rand.Next(0, 10)];
                int fn = rand.Next(100000, 999999);
                int groupNumber = rand.Next(1, 3);
                Student student = new Student(firstName, lastName, fn, groupNumber);
                students[i] = student;
            }

            
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Random rand = new Random();
            Student[] students = new Student[10];
            string[] firstNames = new string[] { "Niki", "Doncho", "Pesho", "Maria", "Stamat", "Ivan", "Ivo", "Gosho", "Evlogi", "Svetlin" };
            string[] lastNames = new string[] { "Kostov", "Minkov", "Peshev", "Ivanov", "Stamatov", "Popov", "Kenov", "Goshev", "Hristov", "Nakov" };
            for (int i = 0; i < students.Length; i++)
            {
                string firstName = firstNames[rand.Next(0, 10)];
                string lastName = lastNames[rand.Next(0, 10)];
                int fn = rand.Next(100000, 999999);
                int groupNumber = rand.Next(1, 3);
                Student student = new Student(firstName, lastName, fn, groupNumber);
                students[i] = student;
            }

            Student[] results = students.Where(st => st.GroupNumber == 2).OrderBy(st => st.FirstName).ToArray();
            foreach (var st in results)
            {
                Console.WriteLine("{0} {1}, fak number - {2}, group - {3}", st.FirstName, st.LastName, st.FacultyNumber, st.GroupNumber);
            }
        }
コード例 #4
0
        static void Main()
        {
            Random rand = new Random();
            Student[] students = new Student[10];
            string[] firstNames = new string[] { "Niki", "Doncho", "Pesho", "Maria", "Stamat", "Ivan", "Ivo", "Gosho", "Evlogi", "Svetlin" };
            string[] lastNames = new string[] { "Kostov", "Minkov", "Peshev", "Ivanov", "Stamatov", "Popov", "Kenov", "Goshev", "Hristov", "Nakov" };

            for (int i = 0; i < students.Length; i++)
            {
                string firstName = firstNames[rand.Next(0, 10)];
                string lastName = lastNames[rand.Next(0, 10)];
                string phoneNumber = "0" + rand.Next(2, 10) + rand.Next(100000, 999999);
                Student student = new Student(firstName, lastName);
                student.PhoneNumber = phoneNumber;
                students[i] = student;
            }

            Student[] studentsFromSofia = students.Where(st => st.PhoneNumber.StartsWith("02")).ToArray();

            foreach (var st in studentsFromSofia)
            {
                Console.WriteLine("{0} {1}, phone number {2}", st.FirstName, st.LastName, st.PhoneNumber);
            }
        }
コード例 #5
0
        static void Main()
        {
            Random rand = new Random();
            Student[] students = new Student[10];
            string[] firstNames = new string[] { "Niki", "Doncho", "Pesho", "Maria", "Stamat", "Ivan", "Ivo", "Gosho", "Evlogi", "Svetlin" };
            string[] lastNames = new string[] { "Kostov", "Minkov", "Peshev", "Ivanov", "Stamatov", "Popov", "Kenov", "Goshev", "Hristov", "Nakov" };
            string[] emails = new string[] { "abv.bg", "yahoo.com", "gmail.com" };
            for (int i = 0; i < students.Length; i++)
            {
                string firstName = firstNames[rand.Next(0, 10)];
                string lastName = lastNames[rand.Next(0, 10)];
                string email = firstName + lastName + "@" + emails[rand.Next(0, 3)];
                Student student = new Student(firstName, lastName);
                student.Email = email;
                students[i] = student;
            }

            Student[] studentsAbvEmails = students.Where(st => st.Email.IndexOf("abv.bg") >= 0).ToArray();

            foreach (var student in studentsAbvEmails)
            {
                Console.WriteLine("{0} {1}, email --> {2}", student.FirstName, student.LastName, student.Email);
            }
        }