Pre- and Post-Increment/Decrement

The increment and decrement operators are similar to assignments with regard to their usual treatment as statements. Useful for their side effects, they’re typically used in loop constructs, as you will see later. Let’s revisit the example from Chapter 5:

for (int i = 0; i < array.Length; i++){    // Do something}

In fact, in such a setting it doesn’t matter whether prefix or postfix syntax is used for those operators because the only difference lies in the value that gets returned and not in the side effect they’re causing. You’ll see both styles used interchangeably, with some (ancient) C/C++ developers slightly preferring the prefix notation for its performance benefit over the ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.