C#, what is the fundamental difference between
and ? i
i
In C#, the effects of incremental computing symbols and
i
<.> 1. In the order of the incident: i
In contrast to common misunderstandings, and follow the same event order. The prefix form (i) and the suffix form (i) only vary from the value of the last step to be modified.
<.> 2. Return value: i
i
(suffixes of suffix):
The original value of
before the increasing increase. The increasing effect is only reflected in the follow -up use ofi
(prefix increment): The value of i
after the increasing increase. This modified value can be used immediately for further calculation. i
i
The main side effects of these two operators are increasing the value of i
. This operation is irreversible, and the value update variable
<.> 4. Example:
i
Increase i
before using the value of , please use
i
i
i
int i = 1; int result = i++ + 1; // result = 2, i = 2
, not the value updated in the variable. i
i
The suffix is returned to the old value, and the prefix is returned to the new value.
int i = 1; int result = ++i + 1; // result = 3, i = 2
The above is the detailed content of What's the Difference Between `i ` and ` i` in C#?. For more information, please follow other related articles on the PHP Chinese website!