dimanche 19 novembre 2017

Random Number Generator c# No duplicates [duplicate]

This question already has an answer here:

I was just wondering how I can stop duplicate numbers from appearing in a random number generator.

This is the code I have so far:

listBox1.Items.Clear();
        Random rnd = new Random();
        int n = rnd.Next();
        int x = 30;

        do
        {
            listBox1.Items.Add(rnd.Next(0, 100));

        } while ((listBox1.Items.Count != x));

Any help will be very much appreciated, Many thanks




Aucun commentaire:

Enregistrer un commentaire