On Fri, 20 May 2005 16:31:02 +1000, Michael C wrote:
without running it what will this code do. It compiles correctly.
private void X()
{
int i = 0;
{
i++;
MessageBox.Show(i.ToString());
} while(i < 10);
MessageBox.Show("Done");
}
Without compiling and running, my guess is
i gets set to 0
i gets incremented to 1
A message box is displayed showing 1
i < 10 gets evaluated to true, but since you close the loop immediately
with a semicolon, there is no behavioral impact
A message box is displayed showing Done
For a while loop, the loop code follows while. You could also use
do...while, in which case the do goes at the beginning.
--
Tom Porterfield