C# Decimal Explicit(Single to Decimal)

Description

Decimal Explicit(Single to Decimal) defines an explicit conversion of a single-precision floating-point number to a Decimal.

Syntax

Decimal.Explicit(Single to Decimal) has the following syntax.


public static explicit operator decimal (
  float value
)

Parameters

Decimal.Explicit(Single to Decimal) has the following parameters.

  • value - The single-precision floating-point number to convert.

Returns

Decimal.Explicit(Single to Decimal) method returns The converted single-precision floating point number.

Example

The following example converts Single values to Decimal numbers by using the Single to Decimal conversion.


using System;//from   w  w w  . ja v a 2  s.c o m

class DecimalFromSingleDemo
{
    public static void Main( )
    {
        object decValue;
        decValue = (decimal)1.2345E-30F;
        Console.WriteLine( decValue );
    }
}

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