Decimal - Subtract
Subtracts one specified value from another.
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); }
View Source
using System; public static partial class Extensions { /// <summary> /// Subtracts one specified value from another. /// </summary> /// <param name="d1">The minuend.</param> /// <param name="d2">The subtrahend.</param> /// <returns>The result of subtracting from .</returns> public static Decimal Subtract(this Decimal d1, Decimal d2) { return Decimal.Subtract(d1, d2); } }