a = 5
b = a + (a = a + 5)
result b = 15
Why the first \'a\' do not changes after that (a = a + 5)? But why second one changes? What exactly is
Unlike C and C++, the order of evaluation of subexpressions are left to right in C#. That's why the expression
j= ++i + ++i ;
has well defined behavior in C# while undefined in C and C++.
In expression
b = a + (a = a + 5)
left a
will be evaluated first, then a+5
is evaluated and assigned to a
and after addition of both evaluated subexpression, b
will have value 15
.