mercredi 7 octobre 2020

How I can display 4random numbers in 4 textboxes in C# forms?

I want to make a math app in windows forms and I want to display 4 random numbers in 4 textboxes but when I use:

 Random randomNumitor1 = new Random();
        int rndmNMT1 = randomNumitor1.Next(1, 10);
        textBox2.Text = rndmNMT1.ToString();
        Random randomNumitor2 = new Random();
        int rndmNMT2 = randomNumitor2.Next(1, 10);
        textBox4.Text = rndmNMT2.ToString();
        Random randomNumarator1 = new Random();
        int rndmNMRT1 = randomNumarator1.Next(1, 10);
        textBox1.Text = rndmNMRT1.ToString();
        Random randomNumarator2 = new Random();
        int rndmNMRT2 = randomNumarator2.Next(1, 10);
        textBox3.Text = rndmNMRT2.ToString();

the app is generating the 4 same numbers. Can somebody help me to modify this code to display 4 different numbers. I want to say I will use it for a fraction resolving exercise. Help me please!




Aucun commentaire:

Enregistrer un commentaire