do (C# Reference)
The do statement executes a statement or a block of statements repeatedly until a specified expression evaluates to false. The body of the loop must be enclosed in braces, {}, unless it consists of a single statement. In that case, the braces are optional.
In the following example, the do-while loop statements execute as long as the variable x is less than 5.
Unlike the while statement, a do-while loop is executed one time before the conditional expression is evaluated.
At any point in the do-while block, you can break out of the loop using the break statement. You can step directly to the while expression evaluation statement by using the continue statement. If the while expression evaluates to true, execution continues at the first statement in the loop. If the expression evaluates to false, execution continues at the first statement after the do-while loop.
A do-while loop can also be exited by the goto, return, or throw statements.
For more information, see the C# Language Specification. The language specification is the definitive source for C# syntax and usage.
Just like other iteration and selection statements, the "{}" aren't necessary if there's one single nested statement within--according to the C# specification (v4.0) and my experience (Visual Studio 2010). For instance, substitute in the example above:
int x = 0;
do Console.WriteLine(x++); while (x < 5);
Edit from SJ at MSFT: Hi Javier. We usually include the braces, even when the body of the loop is a single statement. However, I will work on the wording of that first sentence. I can see that it could be interpreted as meaning that the braces are always required. Thanks for the observation.
Javier: Yes I only meant the textual mention of the braces, of course example code must be as didactic as possible. It's a minutia, but since I had spotted it. Thanks for answering.