Randomize within boundaries

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
 
G

Guest

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top