lundi 18 novembre 2019

Random Number without duplicate

I want to generate a random numbers and view them in textbox without duplicate, so each time I click on the button, it should show a unique number. Any ideas how can I do that please?

here is my Code:

private void timer1_Tick(object sender, EventArgs e)
        {
            int num;
            Random rnd = new Random();
            num = rnd.Next(1, 501);
            lblWin.Text = Convert.ToString(num);

        }

private void start_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }



Aucun commentaire:

Enregistrer un commentaire