using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ABC
{
static class Program
{
static void Main(string[] args)
{
List<int> L = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, };
List<int> L2 = L.Swap(0, 9).ShowConsole().ToList();
return;
}
public static IEnumerable<T> Swap<T>(this IEnumerable<T> Collection, int IdxA, int IdxB)
{
for (int i = 0; i < Collection.Count(); i++)
{
if (i == IdxA)
{
yield return Collection.ElementAt(IdxB);
continue;
}
if (i == IdxB)
{
yield return Collection.ElementAt(IdxA);
continue;
}
yield return Collection.ElementAt(i);
}
}
public static IEnumerable<T> ShowConsole<T>(this IEnumerable<T> Collection)
{
foreach (var o in Collection)
{
Console.WriteLine(o);
}
return Collection;
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkxpbnE7CnVzaW5nIFN5c3RlbS5UZXh0OwoKbmFtZXNwYWNlIEFCQwp7CiAgICBzdGF0aWMgY2xhc3MgUHJvZ3JhbQogICAgewogICAgICAgIHN0YXRpYyB2b2lkIE1haW4oc3RyaW5nW10gYXJncykKICAgICAgICB7CiAgICAgICAgICAgIExpc3Q8aW50PiBMID0gbmV3IExpc3Q8aW50PigpIHsgMCwgMSwgMiwgMywgNCwgNSwgNiwgNywgOCwgOSwgfTsKCiAgICAgICAgICAgIExpc3Q8aW50PiBMMiA9IEwuU3dhcCgwLCA5KS5TaG93Q29uc29sZSgpLlRvTGlzdCgpOwoKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyBJRW51bWVyYWJsZTxUPiBTd2FwPFQ+KHRoaXMgSUVudW1lcmFibGU8VD4gQ29sbGVjdGlvbiwgaW50IElkeEEsIGludCBJZHhCKQogICAgICAgIHsKICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBDb2xsZWN0aW9uLkNvdW50KCk7IGkrKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYgKGkgPT0gSWR4QSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICB5aWVsZCByZXR1cm4gQ29sbGVjdGlvbi5FbGVtZW50QXQoSWR4Qik7CiAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoaSA9PSBJZHhCKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHlpZWxkIHJldHVybiBDb2xsZWN0aW9uLkVsZW1lbnRBdChJZHhBKTsKICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHlpZWxkIHJldHVybiBDb2xsZWN0aW9uLkVsZW1lbnRBdChpKTsKICAgICAgICAgICAgfQogICAgICAgIH0gCiAgICAgICAgcHVibGljIHN0YXRpYyBJRW51bWVyYWJsZTxUPiBTaG93Q29uc29sZTxUPih0aGlzIElFbnVtZXJhYmxlPFQ+IENvbGxlY3Rpb24pCiAgICAgICAgewoKICAgICAgICAgICAgZm9yZWFjaCAodmFyIG8gaW4gQ29sbGVjdGlvbikKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUobyk7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHJldHVybiBDb2xsZWN0aW9uOwogICAgICAgIH0KICAgIH0KfQ==