BigInteger.UnaryNegation(BigInteger) 运算符

定义

对指定的 BigInteger 值求反。Negates a specified BigInteger value.

public:
 static System::Numerics::BigInteger operator -(System::Numerics::BigInteger value);
public static System.Numerics.BigInteger operator - (System.Numerics.BigInteger value);
static member ( ~- ) : System.Numerics.BigInteger -> System.Numerics.BigInteger
Public Shared Operator - (value As BigInteger) As BigInteger

参数

value
BigInteger

要求反的值。The value to negate.

返回

value 参数乘以负一 (-1) 的结果。The result of the value parameter multiplied by negative one (-1).

示例

下面的示例演示了使用三种不同的方法来否定 BigInteger 对象的值。The following example illustrates three different ways to negate the value of a BigInteger object.

BigInteger number = 12645002;

Console.WriteLine(BigInteger.Negate(number));        // Displays -12645002
Console.WriteLine(-number);                          // Displays -12645002
Console.WriteLine(number * BigInteger.MinusOne);     // Displays -12645002
Dim number As BigInteger = 12645002

Console.WriteLine(BigInteger.Negate(number))          ' Displays -12645002
Console.WriteLine(-number)                            ' Displays -12645002
Console.WriteLine(number * BigInteger.MinusOne)       ' Displays -12645002

注解

UnaryNegation 方法定义 BigInteger 值的一元求反运算符(或加法逆运算符)的运算。The UnaryNegation method defines the operation of the unary negation operator (or the additive inverse operator) for BigInteger values. 操作将生成一个值,该值将在添加到原始数字时导致为0(零)。The operation produces a value that results in 0 (zero) when it is added to the original number. 不支持自定义运算符的语言可以改为调用 Negate 方法。Languages that do not support custom operators can call the Negate method instead.

此运算符的等效方法是 BigInteger.Negate(BigInteger)The equivalent method for this operator is BigInteger.Negate(BigInteger)

适用于