LANGUAGE

Prefix and postfix increment

Both increment a variable; prefix yields the new value and postfix the old value. Use a separate statement if the expression result is not needed.

Formal Syntax & Structure

csharp syntaxcsharp
++x; x++;

Working Example

Example Snippetcsharp
int n = 4; int old = n++; // old = 4, n = 5
C# & .NET Reference