Nov 18, 2011 at 9:45pm Nov 18, 2011 at 9:45pm UTC
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
Nov 18, 2011 at 10:21pm Nov 18, 2011 at 10:21pm UTC
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.
Nov 22, 2011 at 7:47pm Nov 22, 2011 at 7:47pm UTC
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...