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.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version