One, C # self-increment operator (+ +)
The increment operator (+ +) is the number of operands plus 1.
1. Prefix self-increment operator
The prefix increment operator is "Add 1 first, then use". The result of this operation is the value after the operand plus 1.
For example:
++x; Prefix self-increment operator
2. Postfix increment operator
The suffix increment operator is "first use, plus 1". The result of the operation is the value before the operand plus 1.
For example:
x + +; Postfix increment operator
Second, prompt
The self-increment operator (+ +) applies to numeric and enumeration types.
Iii. examples
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace Test
{
class program
{
static void Main (string[] args)
{
//C # auto-increment operator (+ +)-www.baike369.com
int x = 0;
Console.WriteLine ("The initial value of X is:" + x);
Console.WriteLine ("(++x) x value is:" + (++x));
Console.WriteLine ("After ++x, the value of X is:" + x);
x = 0;
The value of Console.WriteLine (x + +) is: "+ (x + +));
Console.WriteLine (after X + +, the value of × is: "+ x);
Console.ReadLine ();
}
}
}
Operation Result:
The initial value of X is: 0
The value of (++X) x is: 1
After ++x, the value of X is: 1
(x + +) The value is: 0
After X + +, the value is: 1
C # self-increment operator (+ +)