C# Decimal Decimal(Double)
Description
Decimal Decimal(Double)
initializes a new instance
of Decimal to the value of the specified double-precision floating-point
number.
Syntax
Decimal.Decimal(Double)
has the following syntax.
public Decimal(
double value
)
Parameters
Decimal.Decimal(Double)
has the following parameters.
value
- The value to represent as a Decimal.
Example
The following code example creates several Decimal numbers using the constructor overload that initializes a Decimal structure with a Double value.
//from w w w . j av a2s .c o m
using System;
class DecimalCtorDoDemo {
public static void Main() {
try {
decimal decimalNum = new decimal( 1.23456789E+5 );
Console.WriteLine( "{0,31}", decimalNum );
} catch( Exception ex ) {
Console.WriteLine( ex );
}
}
}
The code above generates the following result.