Beispiel #1
0
        static void Main(string[] args)
        {
            Password password1 = new Password();

            Console.WriteLine("Введите пароль:");
            password1.Parol = Console.ReadLine();

            Password password2 = new Password();

            Console.WriteLine("Введите второй пароль:");
            password2.Parol = Console.ReadLine();

            Password password3 = new Password();

            Console.WriteLine("Введите третий пароль:");
            password3.Parol = Console.ReadLine();

            Password password4 = new Password();

            Console.WriteLine("Введите четвёртый пароль:");
            password4.Parol = Console.ReadLine();

            Console.WriteLine("--------------------------------------------------------");

            CollectionType <Password> myCollection = new CollectionType <Password>();

            myCollection.Add(password1);
            myCollection.Add(password2);
            myCollection.Add(password3);
            myCollection.Add(password4);
            myCollection.Check();

            Console.WriteLine("--------------------------------------------------------");

            bool exept = false;

            try
            {
                Password giveMe = myCollection.Delete(2);
                Console.WriteLine($" Извлечённый пароль {giveMe.Parol}");
                myCollection.Check();
            }

            catch (ArgumentOutOfRangeException ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.Source);
                exept = true;
            }
            finally
            {
                if (exept)
                {
                    Console.WriteLine("Исключение обработано");
                }
                else
                {
                    Console.WriteLine("Исключение не обработано либо не произошло");
                }
            }

            Console.WriteLine("--------------------------------------------------------");

            bool exept2 = false;

            try
            {
                StandartTypes <int, double, byte> myTypes = new StandartTypes <int, double, byte>(1234, 123.4, 8); // обобщение для проверки типов
                myTypes.ShowTypes();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.Source);
                exept2 = true;
            }
            finally
            {
                if (exept2)
                {
                    Console.WriteLine("Исключение обработано");
                }
                else
                {
                    Console.WriteLine("Исключение не обработано либо не произошло");
                }
            }

            myCollection.WriteToFile();

            Console.ReadKey();
        }