December 2004
Intermediate to advanced
1008 pages
21h 40m
English
The increment (++) and decrement (--) operators have two usages. That is, they can be used for both pre-operation and post-operation evaluation. When the operators appear before the variable, the operation takes place before the variable is evaluated. When they follow the variable, the operation takes place after the variable has been evaluated. Take a look at the following statements:
int i = 10; Console.WriteLine( i++ ); //prints 10, then increments i to 11 Console.WriteLine( ++i ); //increments i to 12 and prints 12
When the value of i is sent to the WriteLine method the first time, i is evaluated to 10 and that value is passed to the WriteLine method. The variable i is then incremented to 11. On the next line, because ...
Read now
Unlock full access