/// <summary> /// 产生在两个值之间的不重复随机数组,长度为aMax - aMin + 1 /// </summary> /// <param name="aMin">最小值</param> /// <param name="aMax">最大值</param> /// <returns>随机数组</returns> static int[] RandomArray( int aMin, int aMax ) { int length = aMax - aMin + 1; int[] result = new int[length]; List<int> list = new List<int>( length ); for (int i = aMin; i <=aMax; i++) { list.Add( i ); } Random rnd=new Random(); for (int i = 0; i < length; i++) { int index=rnd.Next(0,list.Count-1); result[i] = list[index]; list.RemoveAt( index ); } return result; }