static void Main() { // Создадим экземпляр обобщенного класса типа int MyObj <int> obj1 = new MyObj <int>(25); obj1.objectType(); MyObjects <string, byte, decimal> obj2 = new MyObjects <string, byte, decimal>("Alex", 26, 12.333m); obj2.objectsType(); Console.ReadLine(); }
static void Main() { Console.WriteLine("Сколько элементов хотите добавить в массив MyArrInt?"); int t1 = int.Parse(Console.ReadLine()); int[] MyArrInt = new int[t1]; MyObj <int> IntConst = new MyObj <int>(MyArrInt.Length, MyArrInt); for (int y = 0; y < t1; y++) { Console.WriteLine("MyArrInt[{0}]: ", y); var k = int.Parse(Console.ReadLine()); IntConst.Add(MyArrInt, k); } Console.WriteLine("Ваш массив: "); for (int y = 0; y < t1; y++) { Console.WriteLine("MyArrInt[{0}]={1}", y, MyArrInt[y]); } Console.WriteLine("Введите индекс элемента, который хотите удалить: "); int q = int.Parse(Console.ReadLine()); try { IntConst.Exception(MyArrInt, q, t1); IntConst.Del(MyArrInt, q); Console.WriteLine("Указанный элемент удалён. Теперь ваш массив: "); for (int y = 0; y < t1 - 1; y++) { Console.WriteLine("MyArrInt[{0}]={1}", y, MyArrInt[y]); } } catch (FormatException ex) { Console.Write(ex.Message + "\n"); Console.Write(ex.TargetSite + "\n"); if (ex.Data != null) { foreach (DictionaryEntry d in ex.Data) { Console.WriteLine(d.Value); } } } catch { } finally { } IntConst.SaveFile(MyArrInt); //работа с double Console.WriteLine("Сколько элементов хотите добавить в массив MyArrDouble?"); int t = int.Parse(Console.ReadLine()); double[] MyArrDouble = new double[t]; MyObj <double> DoubleConst = new MyObj <double>(MyArrDouble.Length, MyArrDouble); for (int y = 0; y < t; y++) { Console.WriteLine("MyArrDouble[{0}]: ", y); var k = double.Parse(Console.ReadLine()); DoubleConst.Add(MyArrDouble, k); } Console.WriteLine("Ваш массив: "); for (int y = 0; y < t; y++) { Console.WriteLine("MyArrDouble[{0}]={1}", y, MyArrDouble[y]); } Console.WriteLine("Введите индекс элемента, который хотите удалить: "); int q1 = int.Parse(Console.ReadLine()); try { DoubleConst.Exception(MyArrDouble, q1, t); DoubleConst.Del(MyArrDouble, q1); Console.WriteLine("Указанный элемент удалён. Теперь ваш массив: "); for (int y = 0; y < t - 1; y++) { Console.WriteLine("MyArrDouble[{0}]={1}", y, MyArrDouble[y]); } } catch (FormatException ex) { Console.Write(ex.Message + "\n"); Console.Write(ex.TargetSite + "\n"); if (ex.Data != null) { foreach (DictionaryEntry d in ex.Data) { Console.WriteLine(d.Value); } } } catch { } finally { } }