The Decimal.Divide()
method is used to divide two decimal numbers.
public static decimal Divide (decimal d1, decimal d2);
d1
: This is the dividend. We will use this decimal number to divide.
d2
: This is the divisor. We will use this decimal number to divide d1
.
This method returns a decimal value, which is the result of dividing d1
and d2
.
// use Systemusing System;// create classclass DecimalDivider{// main methodstatic void Main(){// create decimal valuesdecimal d1 = Decimal.Divide(20.10m, 2.0m);decimal d2 = Decimal.Divide(40.4m, 5.2m);decimal d3 = Decimal.Divide(33.33m, 11.11m);// print resultsConsole.WriteLine(d1);Console.WriteLine(d2);Console.WriteLine(d3);}}
We divide decimal numbers with divisors using the Decimal.Divide()
method in the code above. In this code:
Decimal.Divivde()
.