Random Number but with Specific Numbers...

I know how to get a random number between two values...ie rand.Next(1, 10)

However, would it be possible to pick a random number for a given set?

For example, I would like to be able to pick a random number from the following: {4, 6, 7, 9}, but not the numbers in between.

Thanks,

Wes
In the above example your set has 4 elements.

You could pick a random number between [1..4] and then use that as an index to retrieve from your set.
You can make an array, initialize the terms to your set, and then use the random number generated to access corresponding random number from the array...
Topic archived. No new replies allowed.