See the following:
for (int i=0; i<2; i++) {
// do some stuff
r = new Random((int)DateTime.Now.Ticks);
iRandom = r.Next(30000);
// do some other stuff
}
Don't ask me how, but iRandom is sometimes the same for both iterations of the loop. I need iRandom to be different for each iteration. How do I do this?
Change your loop to this:
r = new Random((int)DateTime.Now.Ticks);
for (int i=0; i<2; i++) {
// do some stuff
iRandom = r.Next(30000);
// do some other stuff
}
In other words, put the creation of the Random object outside the loop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With