次の方法で共有


Decimal コンストラクタ (UInt32)

Decimal の新しいインスタンスを作成して、その値を、指定した 32 ビット符号なし整数に設定します。

このコンストラクタは、CLS に準拠していません。  

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)

構文

'宣言
<CLSCompliantAttribute(False)> _
Public Sub New ( _
    value As UInteger _
)
'使用
Dim value As UInteger

Dim instance As New Decimal(value)
[CLSCompliantAttribute(false)] 
public Decimal (
    uint value
)
[CLSCompliantAttribute(false)] 
public:
Decimal (
    unsigned int value
)
/** @attribute CLSCompliantAttribute(false) */ 
public Decimal (
    UInt32 value
)
CLSCompliantAttribute(false) 
public function Decimal (
    value : uint
)

パラメータ

  • value
    Decimal として表す値。

使用例

Decimal 構造体を UInt32 値で初期化するコンストラクタのオーバーロードを使用して、複数の Decimal 数値を作成するコード例を次に示します。

' Example of the Decimal( UInt32 ) constructor.
Imports System
Imports Microsoft.VisualBasic

Module DecimalCtorUIDemo

    ' Create a Decimal object and display its value.
    Sub CreateDecimal( value As UInt32, 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,16}", ctor, decimalNum )
    End Sub
    
    Sub Main( )

        Console.WriteLine( _
            "This example of the Decimal( UInt32 ) constructor " & _
            vbCrLf & "generates the following output." & vbCrLf )
        Console.WriteLine( "{0,-33}{1,16}", "Constructor", "Value" )
        Console.WriteLine( "{0,-33}{1,16}", "-----------", "-----" )

        ' Construct Decimal objects from UInt32 values.
        ' UInt32.MinValue and UInt32.MaxValue are not defined in VB.
        CreateDecimal( Convert.ToUInt32( 0 ), """UInt32.MinValue""" )
        CreateDecimal( Convert.ToUInt32( 4294967295 ), _
            """UInt32.MaxValue""" )
        CreateDecimal( Convert.ToUInt32( Integer.MaxValue ), _
            "Integer.MaxValue" )              
        CreateDecimal( Convert.ToUInt32( 999999999 ), "999999999" ) 
        CreateDecimal( Convert.ToUInt32( &H40000000 ), "&H40000000" ) 
        CreateDecimal( Convert.ToUInt32( &HC0000000L ), "&HC0000000" )
    End Sub 
End Module 

' This example of the Decimal( UInt32 ) constructor
' generates the following output.
' 
' Constructor                                 Value
' -----------                                 -----
' Decimal( "UInt32.MinValue" )                    0
' Decimal( "UInt32.MaxValue" )           4294967295
' Decimal( Integer.MaxValue )            2147483647
' Decimal( 999999999 )                    999999999
' Decimal( &H40000000 )                  1073741824
' Decimal( &HC0000000 )                  3221225472
// Example of the decimal( uint ) constructor.
using System;

class DecimalCtorUIDemo
{
    // Create a decimal object and display its value.
    public static void CreateDecimal( uint 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,-33}{1,16}", ctor, decimalNum );
    }
    
    public static void Main( )
    {
        Console.WriteLine( "This example of the decimal( uint ) " +
            "constructor \ngenerates the following output.\n" );
        Console.WriteLine( "{0,-33}{1,16}", "Constructor", "Value" );
        Console.WriteLine( "{0,-33}{1,16}", "-----------", "-----" );

        // Construct decimal objects from uint values.
        CreateDecimal( uint.MinValue, "uint.MinValue" );
        CreateDecimal( uint.MaxValue, "uint.MaxValue" );
        CreateDecimal( (uint)int.MaxValue, "(uint)int.MaxValue" );
        CreateDecimal( 999999999U, "999999999U" );
        CreateDecimal( 0x40000000U, "0x40000000U" );
        CreateDecimal( 0xC0000000, "0xC0000000" );
    }
}

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

Constructor                                 Value
-----------                                 -----
decimal( uint.MinValue )                        0
decimal( uint.MaxValue )               4294967295
decimal( (uint)int.MaxValue )          2147483647
decimal( 999999999U )                   999999999
decimal( 0x40000000U )                 1073741824
decimal( 0xC0000000 )                  3221225472
*/
// Example of the Decimal( unsigned int ) constructor.
using namespace System;

// Create a Decimal object and display its value.
void CreateDecimal( unsigned int 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,-30}{1,16}", ctor, decimalNum );
}

int main()
{
   Console::WriteLine( "This example of the Decimal( unsigned "
   "int ) constructor \ngenerates the following output.\n" );
   Console::WriteLine( "{0,-30}{1,16}", "Constructor", "Value" );
   Console::WriteLine( "{0,-30}{1,16}", "-----------", "-----" );
   
   // Construct Decimal objects from unsigned int values.
   CreateDecimal( UInt32::MinValue, "UInt32::MinValue" );
   CreateDecimal( UInt32::MaxValue, "UInt32::MaxValue" );
   CreateDecimal( Int32::MaxValue, "Int32::MaxValue" );
   CreateDecimal( 999999999, "999999999" );
   CreateDecimal( 0x40000000, "0x40000000" );
   CreateDecimal( 0xC0000000, "0xC0000000" );
}

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

Constructor                              Value
-----------                              -----
Decimal( UInt32::MinValue )                  0
Decimal( UInt32::MaxValue )         4294967295
Decimal( Int32::MaxValue )          2147483647
Decimal( 999999999 )                 999999999
Decimal( 0x40000000 )               1073741824
Decimal( 0xC0000000 )               3221225472
*/
// Example of the decimal( uint ) constructor.
import System.* ;

class DecimalCtorUIDemo
{   
    // Create a decimal object and display its value.
    public static void CreateDecimal(UInt32 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,-33}{1,16}", ctor, decimalNum);
    } //CreateDecimal

    public static void main(String[] args)
    {
        Console.WriteLine(("This example of the decimal( uint ) "
            + "constructor \ngenerates the following output.\n"));
        Console.WriteLine("{0,-33}{1,16}", "Constructor", "Value");
        Console.WriteLine("{0,-33}{1,16}", "-----------", "-----");
        
        // Construct decimal objects from uint values.
        CreateDecimal(Convert.ToUInt32(UInt64.MinValue) , "uint.MinValue");
        CreateDecimal( UInt32.MaxValue, "uint.MaxValue");
        CreateDecimal(((UInt32) Int32.MaxValue), "(uint)int.MaxValue");
        CreateDecimal(Convert.ToUInt32(999999999), "999999999U");
        CreateDecimal(Convert.ToUInt32(0x40000000), "0x40000000U");
        CreateDecimal((UInt32)(0xC0000000), "0xC0000000");
        
    } //main
} //DecimalCtorUIDemo

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

Constructor                                 Value
-----------                                 -----
decimal( uint.MinValue )                        0
decimal( uint.MaxValue )               4294967295
decimal( (uint)int.MaxValue )          2147483647
decimal( 999999999U )                   999999999
decimal( 0x40000000U )                 1073741824
decimal( 0xC0000000 )                  3221225472
*/

プラットフォーム

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

参照

関連項目

Decimal 構造体
Decimal メンバ
System 名前空間