2
Answers

How to sort text boxes ?

Joey

Joey

12y
1.2k
1
Hi just wondering if somebody could help me.

I have a button that will generate two numbers inside three different text boxes.

I was wondering how I can sort these text boxes so the first number will always be smaller etc..

Thank you

 Random RandomClass = new Random();
        int Num1 = RandomClass.Next(0, 50);
        int Num2 = RandomClass.Next(0, 50);
 int Num3 = RandomClass.Next(0, 50);



        tb1.Text = Num1.ToString(); 
        tb2.Text = Num2.ToString();
 tb3.Text = Num3.ToString();
Answers (2)
1
R ACHUTHA

R ACHUTHA

NA 483 23k 12y
try the following 

        Random RandomClass = new Random();
        int[] Nums = new int[3];
        Nums[0]= RandomClass.Next(0, 50);
        Nums[1] = RandomClass.Next(0, 50);
        Nums[2] = RandomClass.Next(0, 50);
        Array.Sort(Nums);

         tb1.Text = Nums[0].ToString(); 
         tb2.Text = Nums[1].ToString();
         tb3.Text = Nums[2].ToString();

0
Joey

Joey

NA 6 2.3k 12y
Thank you :D