I'm trying to access the value of a random element of an list. At the moment my code seems to be returning the element rather than the value.
int x = _randMoveDecider.Count;
//makes sure x is never more than the array size
if(x != 0)
{
x = x - 1 ;
}
Random _r = new Random();
_move = _r.Next(_randMoveDecider[x]);
return _randMoveDecider[_move];
at the moment if _randMoveDecider holds the values 2, 5 and 9 it will return 0, 1 or 2 rather than the values in the list, where am I going wrong?
[edit] I guess I should have said, the length of _randMoveDecider and the values stored in it change with each run through of the program, but they are always integers.