Table of Contents12345678910111213141516171819202122232425NotesDownloadECMA-334 C# Language Specification14 Expressions14.6 Unary expressions14.6.2 Unary minus operator
Paragraph 11For an operation of the form -x, unary operator overload resolution (§14.2.3) is applied to select a specific operator implementation.2The operand is converted to the parameter type of the selected operator, and the type of the result is the return type of the operator.3The predefined negation operators are:
4 Integer negation:
int operator -(int x);
long operator -(long x);
Paragraph 21The result is computed by subtracting x from zero.2In a checked context, if the value of x is the maximum negative int or long, a System.OverflowException is thrown.3In an unchecked context, if the value of x is the maximum negative int or long, the result is that same value and the overflow is not reported.4If the operand of the negation operator is of type uint, it is converted to type long, and the type of the result is long.5An exception is the rule that permits the int value −2147483648 (−231) to be written as a decimal integer literal (§188.8.131.52).6If the operand of the negation operator is of type ulong, a compile-time error occurs.7An exception is the rule that permits the long value −9223372036854775808 (−263) to be written as a decimal integer literal (§184.108.40.206).