Can you write a swap routine for generic lists covariantly? Here is a swap routine which won't work:
public static void Swap(List<IComparable> list, int pos1, int pos2)
{
IComparable temp = list[pos1];
list[pos1] = list[pos2];
list[pos2] = temp;
}
Calling Swap(new List<int>{1,2}, 0, 1)
won't work here because this version of Swap isn't covariant.