You can try using Fisher-Yates shuffle algorithm
http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
It could be something like that:
public class Dealer {
// Fisher-Yates shuffle algorithm with explicit generator
private static void CoreShuffle(IList<Kort> list, Random generator) {
if (Object.ReferenceEquals(null, list))
throw new ArgumentNullException("list");
else if (Object.ReferenceEquals(null, generator))
throw new ArgumentNullException("generator");
for (int i = list.Count - 1; i >= 0; --i) {
int index = generator.Next(i + 1);
Kurt h = list[index];
list[index] = list[i];
list[i] = h;
}
}
public static Random rand = new Random(); // <- Be careful: Random is not thread safe; readonly is also a good addition here
// Return new shuffled list based on deckOfCards
public List<Kort> ShuffledList() {
List<Kort> result = new List<Kort>(deckOfCards); // <- Check this line in your code
CoreShuffle(result, rand);
return result;
}