To add to the other answers, since you will already have the input numbers you should put them into a collection like a
List<T>
or
Array
. Then generate a random number using
Random.Next(int)
that is bound by 0 and the size of your collection minus 1. Use the result as an index for your collection. The code should look something like this:
double GetRandomElement(IList<double> items, Random rand)
{
int index = rand.Next((int)(items.Count()-1));
return items[index];
}
You should be able to send an
Array
or
List<T>
to this method.