public static void Main(string[] args) { var counter = int.Parse(Console.ReadLine()); var box = new Box <int>(); for (int i = 0; i < counter; i++) { var command = int.Parse(Console.ReadLine()); box.AddElements(command); } var command2 = Console.ReadLine().Split(); var firstIndex = int.Parse(command2[0]); var secondIndex = int.Parse(command2[1]); box.SwapElements(firstIndex, secondIndex); Console.WriteLine(box.ToString()); }
static void Main(string[] args) { Box <string> list = new Box <string>(); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { var input = Console.ReadLine(); list.AddElement(input); } var indexes = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray(); int firstElement = indexes[0]; int secondElement = indexes[1]; list.SwapElements(firstElement, secondElement); Console.WriteLine(String.Join(Environment.NewLine, list)); }
static void Main(string[] args) { List <int> values = new List <int>(); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { int input = int.Parse(Console.ReadLine()); values.Add(input); } Box <int> box = new Box <int>(values); int[] arr = Console.ReadLine() .Split() .Select(int.Parse).ToArray(); int firstElement = arr[0]; int secondElement = arr[1]; box.SwapElements(firstElement, secondElement); Console.WriteLine(box); }