This will show only result 9 ( last result ).
Yes because you assign a new value to Label1.Text property in every iteration.
Try this instead;
int x = 0;
while (x < 10)
{
Label1.Text = Label1.Text + x;
x++;
}
Or instead define a string value outside of while and add it this int values inside of your loop and assign your .Text value outside of your loop like;
int x = 0;
string s = "";
while (x < 10)
{
s += x;
x++;
}
Label1.Text = s;
Or use StringBuilder would be better if you use a lot of numbers;
int x = 0;
StringBuilder s = new StringBuilder();
while (x < 10)
{
s.Append(x);
x++;
}
Label1.Text = s.ToString();
Label1.Text += x+"";StringBuilderand assignLabel1.Textafter loop.StringBuilderhere!!! I Should Use StringBuilder Everywhere, Right? No its not!!