I'm working on a school project and I need to create an array (size of 30) of random unique numbers between 1 and 70.
I managed to find how to create an array of random unique numbers, but not between 1 and 70.
public int[] ShuffleArray(int[] arr)
{
Random rand = new Random();
int[] array = new int[70];
for (int i = 0; i < 70; i++)
array[i] = i + 1;
int[] MyRandomArray = array.OrderBy(x => rand.Next(1, 71)).ToArray();
for (int k = 0; k < arr.Length; k++)
arr[k] = MyRandomArray[k];
return arr;
}
I changed it based on feedback, but it still doesn't work.
Aucun commentaire:
Enregistrer un commentaire