C# Decimal UnaryNegation

Description

Decimal UnaryNegation negates the value of the specified Decimal operand.

Syntax

Decimal.UnaryNegation has the following syntax.


public static decimal operator -(
  decimal d
)

Parameters

Decimal.UnaryNegation has the following parameters.

  • d - The value to negate.

Returns

Decimal.UnaryNegation method returns The result of d multiplied by negative one (-1).

Example


using System;/*from  w  w w. j a  v a2s.c om*/

public class Example
{
   public static void Main()
   {
      Decimal number1 = 120.07m;
      Decimal number2 = -163.19m;
      Decimal number3 = number1 - number2;
      Console.WriteLine(number3);
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version