Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Decimal Constructor (UInt64)

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

This API is not CLS-compliant. 

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

[CLSCompliantAttribute(false)]
public:
Decimal(
	unsigned long long value
)

Parameters

value
Type: System::UInt64

The value to represent as a Decimal.

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( unsigned __int64 ) constructor. 
using namespace System;

// Create a Decimal object and display its value. 
void CreateDecimal( unsigned __int64 value, String^ valToStr )
{
   Decimal decimalNum = Decimal(value);

   // Format the constructor for display.
   String^ ctor = String::Format( "Decimal( {0} )", valToStr );

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

int main()
{
   Console::WriteLine( "This example of the Decimal( unsigned " 
   "__int64 ) constructor \ngenerates the following output.\n" );
   Console::WriteLine( "{0,-33}{1,22}", "Constructor", "Value" );
   Console::WriteLine( "{0,-33}{1,22}", "-----------", "-----" );

   // Construct Decimal objects from unsigned __int64 values.
   CreateDecimal( UInt64::MinValue, "UInt64::MinValue" );
   CreateDecimal( UInt64::MaxValue, "UInt64::MaxValue" );
   CreateDecimal( Int64::MaxValue, "Int64::MaxValue" );
   CreateDecimal( 999999999999999999, "999999999999999999" );
   CreateDecimal( 0x2000000000000000, "0x2000000000000000" );
   CreateDecimal( 0xE000000000000000, "0xE000000000000000" );
}

/*
This example of the Decimal( unsigned __int64 ) constructor
generates the following output.

Constructor                                       Value
-----------                                       -----
Decimal( UInt64::MinValue )                           0
Decimal( UInt64::MaxValue )        18446744073709551615
Decimal( Int64::MaxValue )          9223372036854775807
Decimal( 999999999999999999 )        999999999999999999
Decimal( 0x2000000000000000 )       2305843009213693952
Decimal( 0xE000000000000000 )      16140901064495857664
*/

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft