Decimal - Negate

Returns the result of multiplying the specified value by negative one.

Try it

const string dataFmt = "{0,31}  {1,10}";

public static void Display(Decimal val)
{
	// C# Extension Method: Decimal - Negate
    Console.WriteLine(dataFmt,val, val.Negate());
}

public static void Main()
{
	
	Console.WriteLine(dataFmt, "Original Value", "Negate");
    // Create pairs of decimal objects.
    Display(0M);
    Display(-1M);
    Display(new decimal(1230000000, 0, 0, false, 7));
    Display(0.0012300M);
    Display(10.0012300M);
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     Returns the result of multiplying the specified  value by negative one.
    /// </summary>
    /// <param name="d">The value to negate.</param>
    /// <returns>A decimal number with the value of , but the opposite sign.-or- Zero, if  is zero.</returns>
    public static Decimal Negate(this Decimal d)
    {
        return Decimal.Negate(d);
    }
}