Home >Backend Development >C++ >What's the Key Difference Between `i ` and ` i` in C#?
i
c# i
and i
are operators used to add numerical variables. Although they eventually increase the value of the variables by 1, there are subtle differences in the value of value and return value. i
are not performed at different times of other operations. In both cases, the operation order is the same: i
i
i
Back to the new value. i
The variable itself uses this new value update.
Returns the original, unmodified value.
i
When the completion of the statement or expression, the variable itself uses the value of the value.
and The values returned are based on the temporary copy created in step 2, not the current value of the variable after increment.
<code class="language-C#">int i = 1; int result1 = ++i; // result1 = 2, i = 2 int result2 = i++; // result2 = 1, i = 2</code>side effects and prone variables:
When using temporary copies to increase, another thread may modify the value of the variable. This may lead to unexpected results when using easily lost variables.
The above is the detailed content of What's the Key Difference Between `i ` and ` i` in C#?. For more information, please follow other related articles on the PHP Chinese website!