Skip to content
Discussion options

You must be logged in to vote

Multiple persons have contributed many good and some better answers. Let me recap it here and then accept my own answer.
First thing, to not mix up operator precedence and expression evaluation order. Expressions are evaluated from left-to-right. Check this comment by Eric Lippert:
https://stackoverflow.com/questions/54674728/is-there-an-explanation-for-inline-operators-in-k-c-k-c/54677275#comment96149488_54677275

The C# spec mentions that the i variable in this case is evaluated only once:
https://www.ecma-international.org/wp-content/uploads/ECMA-334_5th_edition_december_2017.pdf
Check 12.18.3 Compound assignment from page 214.

The term “evaluated only once” means that in the evaluatio…

Replies: 4 comments 19 replies

Comment options

You must be logged in to vote
12 replies
@CommonLoon102
Comment options

@333fred
Comment options

@333fred
Comment options

@CommonLoon102
Comment options

@333fred
Comment options

Comment options

You must be logged in to vote
3 replies
@CyrusNajmabadi
Comment options

@CommonLoon102
Comment options

@CommonLoon102
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@CommonLoon102
Comment options

@bernd5
Comment options

@spydacarnage
Comment options

@CommonLoon102
Comment options

Answer selected by CommonLoon102
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants