mardi 17 mars 2020

How do I make it so that a random number isn't repeated? [duplicate]

I am trying to generate 6 random numbers and add them all into an array. I am able to generate the numbers in the range that I want and add them to the array. However, I am not sure how to make sure the number isn't repeated twice. This is what I have so far:

        Random rnd = new Random();
        int[] RandomHorse = new int[6];
        for (int i = 0; i < RandomHorse.Length; i++)
        {
            RandomHorse[i] = rnd.Next(HorseList.Count);
        }



Aucun commentaire:

Enregistrer un commentaire