O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required