dimanche 4 janvier 2015

Im getting this exeption thrown when the method is invoked. the list contains exactly 52 objects(number of cards). Any suggestions what may cause it? maybe the Add and RemoveAt Methods? Or maybe the Random?



public void Shuffle()
{
List<Card> temp = new List<Card>();
Random rand = new Random();
for (int i = 0; i < 52; i++)
{
for (int j = rand.Next(i, 52); j < 52; j++)
{
temp.Add(deck[j]);
deck.RemoveAt(j);
deck.Add(temp[j]);
}
}
}




Aucun commentaire:

Enregistrer un commentaire