The behavior is well defined in C# and the evaluation order is:
- Left side
i
is evaluated to the variablei
- Right side is evaluated to 0, and
i
is incremented (nowi==1
) - The assignment is executed, it sets
i
to 0. (nowi==0
)
The end result is i==0
.
In general you first create an expression tree. To evaluate it you evaluate first the left side, then the right side and finally the operation at the root. Do that recursively.