private static void CommandExecutor(ref GenericCollection <string> genericCollection, string input, ref string result) { string[] commandOfArgs = input .Split(' '); switch (commandOfArgs[0]) { case "Add": genericCollection.Add(commandOfArgs[1]); break; case "Remove": int index = int.Parse(commandOfArgs[1]); genericCollection.Remove(index); break; case "Contains": result = genericCollection.Contains(commandOfArgs[1]).ToString(); break; case "Swap": int index1 = int.Parse(commandOfArgs[1]); int index2 = int.Parse(commandOfArgs[2]); genericCollection.Swap(index1, index2); break; case "Greater": result = genericCollection.CountGreaterThan(commandOfArgs[1]).ToString(); break; case "Max": result = genericCollection.Max(); break; case "Min": result = genericCollection.Min(); break; case "Sort": Sorter sorter = new Sorter(); genericCollection = sorter.Sort(genericCollection); break; case "Print": result = genericCollection.Print(); break; } }
static void Main(string[] args) { int count = int.Parse(Console.ReadLine()); var collection = new GenericCollection <int>(); for (int i = 0; i < count; i++) { var element = int.Parse(Console.ReadLine()); collection.AddElement(element); } string[] indexes = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int firstIndex = int.Parse(indexes[0]); int secondIndex = int.Parse(indexes[1]); collection.SwapElements(firstIndex, secondIndex); collection.Print(); }