Why does this work and produce different random numbers per the SIZE
?
for (int index = 0; index < SIZE; index++)
{
Random rand = new Random();
numbersArray [index] = rand.Next(0, 100);
MessageBox.Show(index.ToString());
}
And yet this produces the same number per the SIZE
?
for (int index = 0; index < SIZE; index++)
{
Random rand = new Random();
numbersArray [index] = rand.Next(0, 100);
}
The only guess i have is that the Random
object gets refreshed when the program pauses?
Aucun commentaire:
Enregistrer un commentaire