C# Decimal Explicit(Decimal to Single)

Description

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

Syntax

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


public static explicit operator float (
  decimal value
)

Parameters

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

  • value - The value to convert.

Returns

Decimal.Explicit(Decimal to Single) method returns A single-precision floating-point number that represents the converted Decimal.

Example

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


//  w w  w. ja  v  a 2s .  c om
using System;

class Example
{
    public static void Main( )
    {
        float dblValue = (float) 0.0000000000123456789123456789M;
        Console.WriteLine(dblValue);
    }
}

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