Decimal Constructor (UInt64)

Decimal Constructor (UInt64)

.NET Framework 4.6 and 4.5

Initializes a new instance of Decimal to the value of the specified 64-bit unsigned integer.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

```[CLSCompliantAttribute(false)]
public Decimal(
ulong value
)
```

Parameters

value
Type: System.UInt64

The value to represent as a Decimal.

Examples

The following code example creates several Decimal numbers using the constructor overload that initializes a Decimal structure with a UInt64 value.

```// Example of the decimal( ulong ) constructor.
using System;

class DecimalCtorLDemo
{
// Create a decimal object and display its value.
public static void CreateDecimal( ulong value, string valToStr )
{
decimal decimalNum = new decimal( value );

// Format the constructor for display.
string ctor = String.Format( "decimal( {0} )", valToStr );

// Display the constructor and its value.
Console.WriteLine( "{0,-35}{1,22}", ctor, decimalNum );
}

public static void Main( )
{
Console.WriteLine( "This example of the decimal( ulong ) " +
"constructor \ngenerates the following output.\n" );
Console.WriteLine( "{0,-35}{1,22}", "Constructor", "Value" );
Console.WriteLine( "{0,-35}{1,22}", "-----------", "-----" );

// Construct decimal objects from ulong values.
CreateDecimal( ulong.MinValue, "ulong.MinValue" );
CreateDecimal( ulong.MaxValue, "ulong.MaxValue" );
CreateDecimal( long.MaxValue, "long.MaxValue" );
CreateDecimal( 999999999999999999, "999999999999999999" );
CreateDecimal( 0x2000000000000000, "0x2000000000000000" );
CreateDecimal( 0xE000000000000000, "0xE000000000000000" );
}
}

/*
This example of the decimal( ulong ) constructor
generates the following output.

Constructor                                         Value
-----------                                         -----
decimal( ulong.MinValue )                               0
decimal( ulong.MaxValue )            18446744073709551615
decimal( long.MaxValue )              9223372036854775807
decimal( 999999999999999999 )          999999999999999999
decimal( 0x2000000000000000 )         2305843009213693952
decimal( 0xE000000000000000 )        16140901064495857664
*/
```

Version Information

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1