Decimal の新しいインスタンスを作成し、その値を、指定した 64 ビット符号付き整数に設定します。
名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文
'宣言
Public Sub New ( _
value As Long _
)
'使用
Dim value As Long
Dim instance As New Decimal(value)
public Decimal (
long value
)
public:
Decimal (
long long value
)
public Decimal (
long value
)
public function Decimal (
value : long
)
パラメータ
- value
Decimal として表す値。
使用例
Decimal 構造体を Int64 値で初期化するコンストラクタのオーバーロードを使用して、複数の Decimal 数値を作成するコード例を次に示します。
' Example of the Decimal( Long ) constructor.
Imports System
Imports Microsoft.VisualBasic
Module DecimalCtorLDemo
' Create a Decimal object and display its value.
Sub CreateDecimal( value As Long, 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,-30}{1,22}", ctor, decimalNum )
End Sub
Sub Main( )
Console.WriteLine( _
"This example of the Decimal( Long ) constructor " & _
vbCrLf & "generates the following output." & vbCrLf )
Console.WriteLine( "{0,-30}{1,22}", "Constructor", "Value" )
Console.WriteLine( "{0,-30}{1,22}", "-----------", "-----" )
' Construct Decimal objects from Long values.
CreateDecimal( Long.MinValue, "Long.MinValue" )
CreateDecimal( Long.MaxValue, "Long.MaxValue" )
CreateDecimal( 0L, "0" )
CreateDecimal( 999999999999999999, "999999999999999999" )
CreateDecimal( &H2000000000000000, "&H2000000000000000" )
CreateDecimal( &HE000000000000000, "&HE000000000000000" )
End Sub
End Module
' This example of the Decimal( Long ) constructor
' generates the following output.
'
' Constructor Value
' ----------- -----
' Decimal( Long.MinValue ) -9223372036854775808
' Decimal( Long.MaxValue ) 9223372036854775807
' Decimal( 0 ) 0
' Decimal( 999999999999999999 ) 999999999999999999
' Decimal( &H2000000000000000 ) 2305843009213693952
' Decimal( &HE000000000000000 ) -2305843009213693952
// Example of the decimal( long ) constructor.
using System;
class DecimalCtorLDemo
{
// Create a decimal object and display its value.
public static void CreateDecimal( long 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( long ) " +
"constructor \ngenerates the following output.\n" );
Console.WriteLine( "{0,-35}{1,22}", "Constructor", "Value" );
Console.WriteLine( "{0,-35}{1,22}", "-----------", "-----" );
// Construct decimal objects from long values.
CreateDecimal( long.MinValue, "long.MinValue" );
CreateDecimal( long.MaxValue, "long.MaxValue" );
CreateDecimal( 0L, "0L" );
CreateDecimal( 999999999999999999, "999999999999999999" );
CreateDecimal( 0x2000000000000000, "0x2000000000000000" );
CreateDecimal( unchecked( (long)0xE000000000000000 ),
"(long)0xE000000000000000" );
}
}
/*
This example of the decimal( long ) constructor
generates the following output.
Constructor Value
----------- -----
decimal( long.MinValue ) -9223372036854775808
decimal( long.MaxValue ) 9223372036854775807
decimal( 0 ) 0
decimal( 999999999999999999 ) 999999999999999999
decimal( 0x2000000000000000 ) 2305843009213693952
decimal( (long)0xE000000000000000 ) -2305843009213693952
*/
// Example of the Decimal( __int64 ) constructor.
using namespace System;
// Create a Decimal object and display its value.
void CreateDecimal( __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,-35}{1,22}", ctor, decimalNum );
}
int main()
{
Console::WriteLine( "This example of the Decimal( __int64 ) "
"constructor \ngenerates the following output.\n" );
Console::WriteLine( "{0,-35}{1,22}", "Constructor", "Value" );
Console::WriteLine( "{0,-35}{1,22}", "-----------", "-----" );
// Construct Decimal objects from __int64 values.
CreateDecimal( Int64::MinValue, "Int64::MinValue" );
CreateDecimal( Int64::MaxValue, "Int64::MaxValue" );
CreateDecimal( 0, "0" );
CreateDecimal( 999999999999999999, "999999999999999999" );
CreateDecimal( 0x2000000000000000, "0x2000000000000000" );
CreateDecimal( 0xE000000000000000, "0xE000000000000000" );
}
/*
This example of the Decimal( __int64 ) constructor
generates the following output.
Constructor Value
----------- -----
Decimal( Int64::MinValue ) -9223372036854775808
Decimal( Int64::MaxValue ) 9223372036854775807
Decimal( 0 ) 0
Decimal( 999999999999999999 ) 999999999999999999
Decimal( 0x2000000000000000 ) 2305843009213693952
Decimal( 0xE000000000000000 ) -2305843009213693952
*/
// Example of the decimal( long ) constructor.
import System.* ;
class DecimalCtorLDemo
{
// Create a decimal object and display its value.
public static void CreateDecimal(long 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( long ) "
+ "constructor \ngenerates the following output.\n"));
Console.WriteLine("{0,-35}{1,22}", "Constructor", "Value");
Console.WriteLine("{0,-35}{1,22}", "-----------", "-----");
// Construct decimal objects from long values.
CreateDecimal(Long.MIN_VALUE, "long.MinValue");
CreateDecimal(Long.MAX_VALUE, "long.MaxValue");
CreateDecimal(0L, "0");
CreateDecimal(999999999999999999L, "999999999999999999");
CreateDecimal(0x2000000000000000L, "0x2000000000000000");
CreateDecimal((long)(0xE000000000000000L), "(long)0xE000000000000000");
} //main
} //DecimalCtorLDemo
/*
This example of the decimal( long ) constructor
generates the following output.
Constructor Value
----------- -----
decimal( long.MinValue ) -9223372036854775808
decimal( long.MaxValue ) 9223372036854775807
decimal( 0 ) 0
decimal( 999999999999999999 ) 999999999999999999
decimal( 0x2000000000000000 ) 2305843009213693952
decimal( (long)0xE000000000000000 ) -2305843009213693952
*/
プラットフォーム
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