C# Decimal Explicit(Double to Decimal)

Description

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

Syntax

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


public static explicit operator decimal (
  double value
)

Parameters

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

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

Returns

Decimal.Explicit(Double to Decimal) method returns The converted double-precision floating point number.

Example

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


/*from w w w  .j  a  v a2 s . c om*/
using System;

class DecimalFromDoubleDemo
{

    public static void Main( )
    {
        object decValue;

        decValue = (decimal)1.23456789012345678E+12;

        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