I am going to generate 100 random numbers in a for loop. The only problem is that since the random() method is timer-based, it will generate the same numbers 3-4 times in a row. I can solve this problem by including a threat.sleep() method in my loop. Therefor i want to know the exact refresh rate of the random() method so that i can match the threat.sleep() method and not get delayed more than necessary.
Here is my code:
for (int i; i <= 100; i += 1)
{
Random rndNum = new Random();
Console.WriteLine(rndNum.Next(1, 100));
Thread.Sleep(X); //I want to know the best value of X (as less delay as possible)
}
Thanks a bunch
/HamMan4Ever
Aucun commentaire:
Enregistrer un commentaire