int x = 10;
x += x--;
In C#/.Net, why does it equal what it equals? (I’m purposely leaving the answer out so you can guess and see if you’re right)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Look at this statement:
This is equivalent to:
Which is equivalent to:
So
xis 20 afterwards – and that’s guaranteed by the spec.What’s also pretty much guaranteed, although not by the spec, is that anyone using such code will be attacked by their colleagues. Yes, it’s good that the result is predictable. No, it’s not good to use that kind of code.