C# Convert ToDecimal(Double)
Description
Convert ToDecimal(Double)
converts the value of the
specified double-precision floating-point number to an equivalent decimal
number.
Syntax
Convert.ToDecimal(Double)
has the following syntax.
public static decimal ToDecimal(
double value
)
Parameters
Convert.ToDecimal(Double)
has the following parameters.
value
- The double-precision floating-point number to convert.
Returns
Convert.ToDecimal(Double)
method returns A decimal number that is equivalent to value.
Example
//ww w. j a va 2 s . c o m
using System;
public class MainClass{
public static void Main(String[] argv){
Console.WriteLine(Convert.ToDecimal(123456789012345678.12D));
Console.WriteLine(Convert.ToDecimal(123456789012346543.12D));
Console.WriteLine(Convert.ToDecimal(10030.12345678905D));
Console.WriteLine(Convert.ToDecimal(10030.12345678915D));
}
}
The code above generates the following result.