C# Extension Method: Decimal - Subtract

CSharp · Console

/Program.cs

// C# Extension Method
// Doc: https://csharp-extension.com/en/method/1002287/decimal-subtract

// @nuget: Z.ExtensionMethods

using System;
					
public class Program
{
	const string dataFmt = "{0,-45}{1,31}";

    public static void Display(Decimal Left, Decimal Right)
    {
		var strValue = Left + " - " + Right;
		// C# Extension Method: Decimal - Subtract
        Console.WriteLine(dataFmt, strValue, Left.Subtract(Right));
    }

    public static void Main()
    {
        // Create pairs of decimal objects.
        Display(1000M, 7M);
        Display(-1000M, 7M);
        Display(new decimal(1230000000, 0, 0, false, 7), 0.0012300M);
        Display(12345678900000000M, 0.0000000012345678M);
        Display(123456789.0123456789M, 123456789.1123456789M);
    }
}
;