C# Decimal Decimal(Single)
Description
Decimal Decimal(Single)
initializes a new instance
of Decimal to the value of the specified single-precision floating-point
number.
Syntax
Decimal.Decimal(Single)
has the following syntax.
public Decimal(
float value
)
Parameters
Decimal.Decimal(Single)
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 Single value.
using System;/*from ww w . jav a2 s . co m*/
class DecimalCtorSDemo
{
public static void Main( )
{
decimal decimalNum = new decimal( 12 );
Console.WriteLine( 1.2345E+5F );
}
}
The code above generates the following result.