Since I have never been a fulltime C, C++, or C# programmer I have always had to go back and "hit" the book / on-line documentation everytime I wanted to use the increment / decrement operators. It use to frustrate me that I couldn't remember something so simple.

When I saw this post I had to respond because one of my C# reference books (C# For Dummies) included the history of these operators. I stashed this history away because I remember hearing a college instructor saying, "Industry won't consider you to be a true C programmer unless you use pointers and the increment / decrement operators."

After reading the history of the increment / decrement operators, if Bronson feels more comfortable using the longer but more intuitive notation -- he should go for it.

**History of the increment / decrement operators:**

Why have an increment operator, and why two of them?

The reason for the increment operator lies in the obscure fact that the PDP-8 computer of the 1970’s had an increment instruction. This would be of little interest today were it not for the fact that the C language, the original precursor to C#, was originally written for the PDP-8. Because that machine had an increment instruction, n++ generated fewer machine instructions than n = n + 1. As slow as those machines were, saving a few machine instructions was a big deal.

Today, compilers are smarter and there’s no difference in the execution time for n++ and n = n + 1 so the need for the increment operator has gone away. However, programmers are creatures of habit, and the operator remains to this day. You almost never a C++ programmer increment a value using the longer but more intuitive n = n + 1. Instead, you see the increment operator.

Further, when standing by itself (that is, not part of a larger expression), the post-increment operator almost always appears instead of the pre-increment. There’s no reason other than habit and the fact that it looks cooler.

C# actually has has two increment operators: ++n and n++ The first one, ++n, is called the preincrement operator, while n++ is the postincrement, The difference is subtle but important.

int n;

n = 1;

int o = ++n; // the value of o is 2. ++n is the value of n after being incremented.

n = 1;

int m = n++ the // the value of m is 1. n++ is the value of n before it is incremented.

Either way, the resulting value value of n is 2.

Equivalent decrement operators - that is, n-- and --n - exist to replace n = n -1. These work in exactly the same way as the increment operators.