C# Decimal Negate

Description

Decimal Negate returns the result of multiplying the specified Decimal value by negative one.

Syntax

Decimal.Negate has the following syntax.


public static decimal Negate(
  decimal d
)

Parameters

Decimal.Negate has the following parameters.

  • d - The value to negate.

Returns

Decimal.Negate method returns A decimal number with the value of d, but the opposite sign. -or- Zero, if d is zero.

Example

Example of the decimal.Negate method.


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

class MainClass{

    public static void Main( )
    {
        Console.WriteLine( decimal.Negate( -123.456M ) );
    }
}

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