How do I generate a random integer in C#?
While this is okay:
Random random = new Random();
int randomNumber = random.Next()
You'd want to control the limit (min and max mumbers) most of the time. So you need to specify where the random number starts and ends.
The Next()
method accepts two parameters, min and max.
So if i want my random number to be between say 5 and 15, I'd just do
int randomNumber = random.Next(5, 16)