Wot to write in order to find the maximum number?

I wrote the following :
int r;
foreach(TextBox t in panel1.controls)
{
r=rnd.next(100);
t.text=r.tostring();
}
my aim is to randomize numbers for 5 textboxes in a panel and then i want to show the maximum number in a separate textbox called tmax.
WHO CAN HELP


Answer this question

Wot to write in order to find the maximum number?

  • Roman Uvarov

    hi,

    i guess you can do that by using variable something like this

    int r;

    int max = 0;
    foreach(TextBox t in panel1.controls)
    {
    r=rnd.next(100);

    if(r>max)

    max = r;
    t.text=r.tostring();
    }

    tmax.text = max;

    hope this helps



  • Wot to write in order to find the maximum number?