Well, smack me with a wet kipper, I have never really considered the difference between do and do while, since I have always just used a while loop.
Anyway, the difference is, that a do-while will always execute before checking the condtion, whereas a while loop, checks the condition before executing the code block.
Quite a fundamental difference that could prove to be useful, I definetly see a 'gotcha!' interview question from this one if it was ever asked.
class Program
{
static void Main()
{
int x = 0;
// Will always output "Hello World"
do
{
Console.WriteLine("Hello World");
x++;
} while (x <= 0);
// Will not output anything
while (x <= 0)
{
Console.WriteLine("Hello World");
x++;
}
}
}