Export (0) Print
Expand All

Decimal Constructor (UInt32)

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

This API is not CLS-compliant. 

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

'Declaration
<CLSCompliantAttribute(False)> _
Public Sub New ( _
	value As UInteger _
)

Parameters

value
Type: System.UInt32

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 UInt32 value.

' 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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

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

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft