I read this post about card shuffling and in many shuffling and sorting algorithms you need to swap two items in a list or array. But what does a good and effecient Swap method look like? Lets say for a T[]
and for a List<T>
. How would you best implement a method that swaps two items in those two?
Swap(ref cards[i], ref cards[n]); // How is Swap implemented?