Synopsis: | Do not access a modified object more than once in an expression |
Language: | C# |
Severity Level: | 5 |
Category: | Control flow |
Description: |
The evaluation order of sub-expressions within an expression is defined in C#, in contrast to C or C++, but such code is hard to understand. Example:
v[i] = ++c; // right v[i] = ++i; // wrong: is v[i] or v[++i] being assigned to? i = i + 1; // right i = ++i + 1; // wrong and useless; i += 2 would be clearer |