------解决方案-------------------- int[] a = new int[100]; Random rnd = new Random(); for (int i = 0; i < 100; i++) { a[i] = rnd.Next(0, 100); }
------解决方案--------------------
C# code
int[] a = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var ram = new Random();
var index = ram.Next(a.Length);
var result = a[index];
------解决方案--------------------
------解决方案-------------------- int [] arr={1,2,3,4,5,6,7}; Random r=new Random(); int i=arr[r.Next(arr.Length)];