Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Write name: ");
            string sName = Console.ReadLine(); // ввод данных студента

            Console.WriteLine("Write ID: ");
            string sId = Console.ReadLine();

            Console.WriteLine("Write year of study: ");
            int    sYear;
            string num = Console.ReadLine(); // для того что бы юсер не ввел буквы вместо цифр
            bool   res = false;

            while (!res)
            {
                res = int.TryParse(num, out sYear);
                if (res)
                {
                    break;
                }
                Console.WriteLine("Error: you must write number.");
                num = Console.ReadLine();
            }
            sYear = int.Parse(num);
            Student s = new Student(sName, sId); // конструктор

            s.data();
            Console.WriteLine("Next Year of study: " + s.NextYear(sYear));
        }