disable broken tests on net_4_0
[mcs.git] / docs / ecma334 / 14.5.9.xml
blob9d4e75e3c2ce97c82438dd51bbc4c23b6c5776f4
1 <?xml version="1.0"?>
2 <clause number="14.5.9" title="Postfix increment and decrement operators">
3   <paragraph>
4     <grammar_production><name><non_terminal where="14.5.9">post-increment-expression</non_terminal></name> : <rhs><non_terminal where="14.5">primary-expression</non_terminal><terminal>++</terminal></rhs></grammar_production>
5     <grammar_production><name><non_terminal where="14.5.9">post-decrement-expression</non_terminal></name> : <rhs><non_terminal where="14.5">primary-expression</non_terminal><terminal>--</terminal></rhs></grammar_production>
6   </paragraph>
7   <paragraph>The operand of a postfix 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>
8   <paragraph>If the operand of a postfix 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>
9   <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>
10   <paragraph>The run-time processing of a postfix 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 value of x is saved. </list_item><list_item> The selected operator is invoked with the saved 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 saved value of x 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 and the returned value is saved. </list_item><list_item> The selected operator is invoked with the saved value of x 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 saved value of x becomes the result of the operation. </list_item></list></list></paragraph>
11   <paragraph>The ++ and  --operators also support prefix notation (<hyperlink>14.6.5</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>
12   <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>
13 </clause>