public static List<T> Swap<T>(this List<T> list, int index1,int index2)
{
if(index1<0||index1>=list.Count)
{
throw new Exception("index1");
}
if (index2 < 0 || index2 >= list.Count)
{
throw new Exception("index2");
}
var temp = list[index1];
list[index1] = list[index2];
list[index2] = temp;
return list;
}