<?xml version="1.0"?>
<clause number="14.6.5" title="Prefix increment and decrement operators">
  <paragraph>
    <grammar_production><name><non_terminal where="14.6.5">pre-increment-expression</non_terminal></name> : <rhs><terminal>++</terminal><non_terminal where="14.6">unary-expression</non_terminal></rhs></grammar_production>
    <grammar_production><name><non_terminal where="14.6.5">pre-decrement-expression</non_terminal></name> : <rhs><terminal>--</terminal><non_terminal where="14.6">unary-expression</non_terminal></rhs></grammar_production>
  </paragraph>
  <paragraph>The operand of a prefix increment or decrement operation must be an expression classified as a variable, a property access, or an indexer access. The result of the operation is a value of the same type as the operand. </paragraph>
  <paragraph>If the operand of a prefix increment or decrement operation is a property or indexer access, the property or indexer must have both a get and a set accessor. If this is not the case, a compile-time error occurs. </paragraph>
  <paragraph>Unary operator overload resolution (<hyperlink>14.2.3</hyperlink>) is applied to select a specific operator implementation. Predefined ++ and  --operators exist for the following types: <keyword>sbyte</keyword>, <keyword>byte</keyword>, <keyword>short</keyword>, <keyword>ushort</keyword>, <keyword>int</keyword>, <keyword>uint</keyword>, <keyword>long</keyword>, <keyword>ulong</keyword>, <keyword>char</keyword>, <keyword>float</keyword>, <keyword>double</keyword>, <keyword>decimal</keyword>, and any enum type. The predefined ++ operators return the value produced by adding 1 to the operand, and the predefined  --operators return the value produced by subtracting 1 from the operand. </paragraph>
  <paragraph>The run-time processing of a prefix increment or decrement operation of the form ++x or --x consists of the following steps: <list><list_item> If x is classified as a variable: </list_item><list><list_item> x is evaluated to produce the variable. </list_item><list_item> The selected operator is invoked with the value of x as its argument. </list_item><list_item> The value returned by the operator is stored in the location given by the evaluation of x. </list_item><list_item> The value returned by the operator becomes the result of the operation. </list_item></list><list_item> If x is classified as a property or indexer access: </list_item><list><list_item> The instance expression (if x is not static) and the argument list (if x is an indexer access) associated with x are evaluated, and the results are used in the subsequent get and set accessor invocations. </list_item><list_item> The get accessor of x is invoked. </list_item><list_item> The selected operator is invoked with the value returned by the get accessor as its argument. </list_item><list_item> The set accessor of x is invoked with the value returned by the operator as its value argument. </list_item><list_item> The value returned by the operator becomes the result of the operation. </list_item></list></list></paragraph>
  <paragraph>The ++ and  --operators also support postfix notation (<hyperlink>14.5.9</hyperlink>). The result of x++ or  x--is the value of x before the operation, whereas the result of ++x or --x is the value of x after the operation. In either case, x itself has the same value after the operation. </paragraph>
  <paragraph>An operator ++ or operator  --implementation can be invoked using either postfix or prefix notation. It is not possible to have separate operator implementations for the two notations. </paragraph>
</clause>
