Why does While loop post-increments (or post-decrements) a variable right after examination of the condition and not after the whole loop?
As in:
int x = 0;
while (x++ < 5)
Console.WriteLine(x);
The output is: 1 2 3 4 5, when I believe it should be 0 1 2 3 4. It seems it checks the condition - true - inrements right away. Is that normal behaviour, becase I've recently been practising Plain C and it's completely different.
Should I rather go with this option for more clarity?
while (x < 5)
Console.WriteLine(x);
++x;