1 //produces n random numbers from min to max consecutive integers2 Private Static int[] Generatenumbers (intMinintMaxintN)3 {4 //seed Array Length5 intSeednum = Max-min +1;6 //seed Array7 int[] Startarray =New int[Seednum];8 9 for(inti =0; i < Seednum; i++)Ten { OneStartarray[i] = min++; A } - //a random number of numbers - int[] Resultarray =New int[n];//the results are stored inside . theRandom rnd =NewRandom (); - for(inti =0; I < n; i++) - { - intSeed = rnd. Next (0, startarray.length-i);//generate from the rest of the random numbers. +Resultarray[i] = Startarray[seed];//Assigning a value to an array of results - //Replace the position where the random number was created with the unchecked value. +Startarray[seed] = startarray[startarray.length-i-1]; A } at - returnresultarray; -}View Code
C # generates non-repeating random numbers