While I am testing post increment operator in a simple console application, I realized that I did not understand full concept. It seems weird to me:
int i = 0;
bool b = i++ == i;
Console.WriteLine(b);
The output has been false. I have expected that it would be true. AFAIK, at line 2, because of the post increment, compiler does comparison and assigned b to true, after i incremented by one. But obviously I am wrong. After that I modify the code like that:
int i = 0;
bool b = i == i++;
Console.WriteLine(b);
This time output has been true. What did change from first sample?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With