C # is evaluated from left to right, so in the first case, you get:
a[2] = 2; // 1)
a[2] = 3; // 2)
In C ++, this behavior is undefined, but since C ++ 17, the assignment operator evaluates from right to left:
a[3] = 2; // 1)
a[3] = 3; // 2)
Different languages, different rules.
source
share