Randomize within boundaries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I dont see in System.Random the ability to set a minimum and maximum value to
perform randomization within a boundary. In other words, Id like to do
something along the lines of:

int minimumValue=1;
int maximumValue=1000;
int randomNumber=Random(minimumValue,maximumValue); // randomNumber will be
a value between 1 and 1000

Is there any code around to do this?
Thanks much, Mark
 
You are going to need to create an instance of Random. Try this:

int minimumValue=1;
int maximumValue=1000;
Random rNum = new Random();
int randomNumber= rNum.Next(minimumValue,maximumValue);
 
Back
Top