jeudi 21 février 2019

random numbers only once in an array c#

I want to generate random numbers and put them in an array, but they should only appear once in this array. It's like a mini lotto game. This is the code I have right now:

int[] arrA = new int[10];
Random random = new Random();

for (int i = 0; i <= arrA.Length -1; i++)
{           
    arrA[i] = random.Next(1, 15);
    Console.WriteLine(arrA[i]);
}

Console.ReadKey();

Random numbers are generated and put in this Array. I only need to know how it's possible to program that they only appeare once.




Aucun commentaire:

Enregistrer un commentaire