public static void DynamicArrDisplay() { var nums = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 }; var arr1 = new DynamicArr33 <int>(); arr1.AddRange(nums); arr1.Add(9); arr1.Add(10); Console.WriteLine("Elements from first array:"); foreach (var i in arr1) { Console.Write(i + " "); } arr1.Remove(5); arr1.Insert(0, 100); Console.WriteLine(); Console.WriteLine("Elements from first array after deleting from middle some element " + "and adding in the begining new element:"); foreach (var i in arr1) { Console.Write(i + " "); } var arr2 = (DynamicArr33 <int>)arr1.Clone(); arr2.Remove(6); Console.WriteLine(); Console.WriteLine("Elements from second array (with removed 6 element):"); foreach (var i in arr2) { Console.Write(i + " "); } Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("TASK 03"); int select; do { Console.Clear(); Console.WriteLine("Select the number of a task:"); Console.WriteLine("1. LOST."); Console.WriteLine("2. WORD FREQUENCY."); Console.WriteLine("3. DYNAMIC ARRAY."); Console.WriteLine("4. DYNAMIC ARRAY (HARDCORE MODE)."); Console.WriteLine("0. Exit."); if (int.TryParse(Console.ReadLine(), out select)) { switch (select) { case 1: Console.Clear(); Console.WriteLine("Task 3.1 LOST:"); var lost = new Lost31(); lost.Lost(); Console.ReadKey(); break; case 2: Console.Clear(); Console.WriteLine("Task 3.2 WORD FREQUENCY:"); var str = new WordFrequency32(); str.WordFrequency(); Console.ReadKey(); break; case 3: Console.Clear(); Console.WriteLine("Task 3.3 DYNAMIC ARRAY:"); DynamicArr33 <int> .DynamicArrDisplay(); Console.ReadKey(); break; case 4: Console.Clear(); Console.WriteLine("Task 3.4 DYNAMIC ARRAY (HARDCORE MODE):"); Console.WriteLine("Task is not completed\n" + "Dear trainer,\n" + "I am in my fourth year at university, so the exam time has been shifted to early December. " + "I have to take exams every day, so unfortunately, I did not have enough time for this task." + " After I pass the exams, I will definitely complete it. Please excuse me.\n" + "Yours sincerely,\n" + "Nikita Vasin\n" + "Student"); Console.ReadKey(); break; case 0: break; default: Console.WriteLine("Wrong number!"); Console.ReadKey(); break; } } else { select = -1; Console.WriteLine("Invalid input!"); Console.ReadKey(); } }while (select != 0); }