How do I generate a random integer in C#?
Beware that new Random()
is seeded on current timestamp.
If you want to generate just one number you can use:
new Random().Next( int.MinValue, int.MaxValue )
For more information, look at the Random class, though please note:
However, because the clock has finite resolution, using the parameterless constructor to create different Random objects in close succession creates random number generators that produce identical sequences of random numbers
So do not use this code to generate a series of random number.