int i = 2;
int j = 3;
int x = j = ++i * j++;
I don't understand why i is equal to 3 after executing everything and j is still equal to 3 instead of 4. Thanks in advance if you answer me.
int i = 2;
int j = 3;
int x = j = ++i * j++;
I don't understand why i is equal to 3 after executing everything and j is still equal to 3 instead of 4. Thanks in advance if you answer me.
Increment operator ++
The unary increment operator ++ increments its operand by 1. The operand must be a variable, property access, or indexer access.
The increment operator is supported in two forms: the postfix increment operator (x++) and the prefix increment operator (++x).
Postfix Increment Operator
The result of x++ is the value of
x antes de la operación
, as shown in the following example:Prefix Increment Operator
The result of ++x is the value of
x después de la operación
, as shown in the following example:Official documentation: https://learn.microsoft.com/es-es/dotnet/csharp/language-reference/operators/arithmetic-operators
The first thing is that there is an error with what you put, j is equal to 9
maybe you wanted to put
To understand, I think it's better to break down the situation
Instead
So in int x = ++i * j++, the equivalent is: