The Decimal.Multiply()
method is used to multiply two decimal values. Decimal.Multiply()
takes two decimal values as parameters. The first parameter is the multiplicand and the second is the multiplier.
This method returns the result of multiplying the two decimal values that are taken as parameters.
public static decimal Multiply (decimal d1, decimal d2);
d1
: The first decimal value, which is the multiplicand.
d2
: The second decimal value, which is the multiplier.
The Decimal.Multiply
method returns the result of multiplying the two decimal values, d1
and d2
.
// use Systemusing System;// create classclass DecimalMultiplier{// main methodstatic void Main(){// create decimal valuesdecimal decimalNumberOne = 34.668m;decimal decimalNumberTwo = 4.9999m;decimal decimalNumberThree = 899.2m;decimal decimalNumberFour = 1.2m;// multiply decimal valuesConsole.WriteLine(Decimal.Multiply(decimalNumberOne, decimalNumberTwo));Console.WriteLine(Decimal.Multiply(decimalNumberThree, decimalNumberFour));}}
Lines 10–13: We create some decimal variables, decimalNumberOne
, decimalNumberTwo
, decimalNumberThree
, and decimalNumberFour
. Then, we initialize them with some values.
Line 16: We use the Decimal.Multiply()
method to multiply decimalNumberOne
with decimalNumberTwo
and print the result.
Line 17: We use the Decimal.Multiply()
method to multiply decimalNumberThree
with decimalNumberFour
and print the result.