////// Get the no repeat random array /// /// The min value of this random array /// The max value of this random array /// The result ranodm array's length ///The result random array static int[] GetNoRepeatRandomArray(int minNumber, int maxNumber, int len) { int[] result = new int[len]; Random ran = new Random(); int[] index = new int[maxNumber]; for (int i = 0; i < index.Length; i++) { index[i] = i; } int id; for (int i = 0; i < len; i++) { id = ran.Next(minNumber, maxNumber); result[i] = index[id]; index[id] = index[maxNumber - 1]; maxNumber--; } return result; }