Decimal の新しいインスタンスを作成して、その値を、指定した 64 ビット符号なし整数に設定します。
このコンストラクタは、CLS に準拠していません。
名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文
'宣言
<CLSCompliantAttribute(False)> _
Public Sub New ( _
value As ULong _
)
'使用
Dim value As ULong
Dim instance As New Decimal(value)
[CLSCompliantAttribute(false)]
public Decimal (
ulong value
)
[CLSCompliantAttribute(false)]
public:
Decimal (
usigned long long value
)
/** @attribute CLSCompliantAttribute(false) */
public Decimal (
UInt64 value
)
CLSCompliantAttribute(false)
public function Decimal (
value : ulong
)
パラメータ
- value
Decimal として表す値。
使用例
Decimal 構造体を UInt64 値で初期化するコンストラクタのオーバーロードを使用して、複数の Decimal 数値を作成するコード例を次に示します。
' Example of the Decimal( UInt64 ) constructor.
Imports System
Imports Microsoft.VisualBasic
Module DecimalCtorULDemo
' Create a Decimal object and display its value.
Sub CreateDecimal( value As UInt64, valToStr As String )
Dim decimalNum As New Decimal( value )
' Format the constructor for display.
Dim ctor As String = _
String.Format( "Decimal( {0} )", valToStr )
' Display the constructor and its value.
Console.WriteLine( "{0,-33}{1,22}", ctor, decimalNum )
End Sub
Sub Main( )
Console.WriteLine( _
"This example of the Decimal( UInt64 ) constructor " & _
vbCrLf & "generates the following output." & vbCrLf )
Console.WriteLine( "{0,-33}{1,22}", "Constructor", "Value" )
Console.WriteLine( "{0,-33}{1,22}", "-----------", "-----" )
' Construct Decimal objects from UInt64 values.
' UInt64.MinValue and UInt64.MaxValue are not defined in VB.
CreateDecimal( Convert.ToUInt64( 0 ), """UInt64.MinValue""" )
CreateDecimal( Convert.ToUInt64( 18446744073709551615D ), _
"""UInt64.MaxValue""" )
CreateDecimal( Convert.ToUInt64( Long.MaxValue ), _
"Long.MaxValue" )
CreateDecimal( Convert.ToUInt64( 999999999999999999 ), _
"999999999999999999" )
CreateDecimal( Convert.ToUInt64( &H2000000000000000 ), _
"&H2000000000000000" )
CreateDecimal( Convert.ToUInt64( 16140901064495857664.0 ), _
"16140901064495857664.0" )
End Sub
End Module
' This example of the Decimal( UInt64 ) constructor
' generates the following output.
'
' Constructor Value
' ----------- -----
' Decimal( "UInt64.MinValue" ) 0
' Decimal( "UInt64.MaxValue" ) 18446744073709551615
' Decimal( Long.MaxValue ) 9223372036854775807
' Decimal( 999999999999999999 ) 999999999999999999
' Decimal( &H2000000000000000 ) 2305843009213693952
' Decimal( 16140901064495857664.0 ) 16140901064495857664
// 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
*/
// 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
*/
// Example of the decimal( ulong ) constructor.
import System.* ;
class DecimalCtorLDemo
{
// Create a decimal object and display its value.
public static void CreateDecimal(UInt64 value, String valToStr)
{
System.Decimal decimalNum = new System.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);
} //CreateDecimal
public static void main(String[] args)
{
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(Long.MIN_VALUE, "ulong.MinValue");
CreateDecimal(UInt64.MinValue, "ulong.MinValue");
CreateDecimal(UInt64.MaxValue, "ulong.MaxValue");
CreateDecimal(System.Convert.ToUInt64(Long.MAX_VALUE), "long.MaxValue");
CreateDecimal(System.Convert.ToUInt64(999999999999999999L),
"999999999999999999" );
CreateDecimal(System.Convert.ToUInt64(0x2000000000000000L),
"0x2000000000000000" );
CreateDecimal((UInt64) 0xE000000000000000L, "0xE000000000000000" );
} //main
} //DecimalCtorLDemo
/*
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
*/
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
.NET Compact Framework
サポート対象 : 2.0、1.0