- () ++ operator - . , 2, 2, 3, .
public static int IncrementByOne(int number)
{
return number++;
}
IL, , :
IncrementByOne:
IL_0000: ldarg.0 // load 'number' onto stack
IL_0001: dup // copy number - this is the reason for the
// postfix ++ behavior
IL_0002: ldc.i4.1 // load '1' onto stack
IL_0003: add // add the values on top of stack (number+1)
IL_0004: starg.s 00 // remove result from stack and put
// back into 'number'
IL_0006: ret // return top of stack (which is
// original value of `number`)
, postfix ++ ( ) - dup - number , ret statment , . number.