random number generator between 0 - 1000 in c#
126,823
Solution 1
Have you tried this
Random integer between 0 and 1000(1000 not included):
Random random = new Random();
int randomNumber = random.Next(0, 1000);
Loop it as many times you want
Solution 2
Use this:
static int RandomNumber(int min, int max)
{
Random random = new Random(); return random.Next(min, max);
}
This is example for you to modify and use in your application.
Related videos on Youtube
Author by
user2636592
Updated on July 09, 2022Comments
-
user2636592 almost 2 years
I need help in writing a program that will generate 100 random numbers between 0 and 1000. The out put needs to be displayed in a windows message box. i'm stuck as to what code I have use to get the numbers in the box and to only have 100 random numbers.
-
Adriaan Stander almost 11 yearsCan you show us the code that you have tried?
-
chancea almost 11 yearsSounds like you should read up on msdn.microsoft.com/en-us/library/ch45axte.aspx and msdn.microsoft.com/en-us/library/system.random.aspx
-
Henrik Høyer almost 3 yearsSee this: stackoverflow.com/questions/2706500/…
-
-
chancea almost 11 years"100 random numbers between 0 and 1000."
-
Joe Shanahan over 10 yearsIf you run this multiple times in succession you would likely end up with the same random number!
-
puddinman13 about 9 yearsI would think you would want to pass min and max values to the Next method. Then call RandomNumber, like so: RandomNumber(1, 1000)