++ Operator (C# Reference) Home
This page is specific to:.NET Framework Version:1.12.03.03.54.0
C# Language Reference
++ Operator (C# Reference)

The increment operator (++) increments its operand by 1. The increment operator can appear before or after its operand:

Remarks

The first form is a prefix increment operation. The result of the operation is the value of the operand after it has been incremented.

The second form is a postfix increment operation. The result of the operation is the value of the operand before it has been incremented.

Numeric and enumeration types have predefined increment operators. User-defined types can overload the ++ operator. Operations on integral types are generally allowed on enumeration.

Example

// cs_operator_increment.cs
using System;
class MainClass
{
    static void Main() 
    {
        double x;
        x = 1.5;
        Console.WriteLine(++x);
        x = 1.5;
        Console.WriteLine(x++);
        Console.WriteLine(x);
    }
}

Output

2.5
1.5
2.5
See Also

Reference

C# Operators

Concepts

C# Programming Guide

Other Resources

C# Reference

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View