Пример #1
0
    public static void Main()
    {
        var boxOfStrings = new GenericBox <int>();

        int n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++)
        {
            int input = int.Parse(Console.ReadLine());

            boxOfStrings.Add(input);
        }

        int[] indexes     = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int   firstIndex  = indexes[0];
        int   secondIndex = indexes[1];

        boxOfStrings.Swap(firstIndex, secondIndex);

        Console.WriteLine(boxOfStrings);
    }
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        List <GenericBox <string> > genericList = new List <GenericBox <string> >();

        for (int i = 0; i < n; i++)
        {
            string input = Console.ReadLine();
            GenericBox <string> genericString = new GenericBox <string>(input);
            genericList.Add(genericString);
        }
        int[] swapPositionsInfo = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int   startIndex        = swapPositionsInfo[0];
        int   lastIndex         = swapPositionsInfo[1];

        GenericBox <string> .Swap(genericList, startIndex, lastIndex);

        foreach (var generic in genericList)
        {
            Console.WriteLine(generic);
        }
    }