Home > Backend Development > C++ > What's the Difference Between `i ` and ` i` in C#?

What's the Difference Between `i ` and ` i` in C#?

DDD
Release: 2025-01-31 08:21:09
Original
454 people have browsed it

What's the Difference Between `i  ` and `  i` in C#?

C#, what is the fundamental difference between

and ? i i In C#, the effects of incremental computing symbols and

are different, mainly reflected in the order of the event and the results of the return. The following are the in -depth explanations of distinguishing these two operators:

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

The key difference is the return value:

(suffixes of suffix):

The original value of

before the increasing increase. The increasing effect is only reflected in the follow -up use of
    .
  • i (prefix increment): The value of i after the increasing increase. This modified value can be used immediately for further calculation. i
  • <.> 3. Side effect: i The main side effects of these two operators are increasing the value of i. This operation is irreversible, and the value update variable
  • will be used after increasing value.

<.> 4. Example:

i Increase i before using the value of , please use

.

    Use to add value immediately, please use
  • .

    i i i

    Other precautions:
      int i = 1;
      int result = i++ + 1; // result = 2, i = 2
    Copy after login
  • The values ​​returned by these two operators are based on the temporary copy of

    , 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
    Copy after login
    The execution order of the increasing operation is clearly defined and consistent with these two forms.
prefix and suffix operators have no effect on priority or binding.

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template