in the following "while" code:
int digit = 0;
while(++digit < 10)
Console.WriteLine(digit);
This prints out 1,2,3,4,5,6,7,8,9 This makes sense to me, since it should stop at 10, since 10<10 is false.
However, when we switch from pre-increment to post-increment for digit:
int digit = 0;
while(digit++ < 10)
Console.WriteLine(digit);
Then it prints out 1,2,3,4,5,6,7,8,9,10
I don't understand why it performs Console.WriteLine and prints out 10 in this case, since 10<10 is false.
Can anyone please explain?
Thanks