Decimal Constructor (UInt32)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Initializes a new instance of Decimal to the value of the specified 32-bit unsigned integer.
Assembly: mscorlib (in mscorlib.dll)
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. Module Example ' Create a Decimal object and display its value. Sub CreateDecimal(ByVal outputBlock As System.Windows.Controls.TextBlock, ByVal value As UInt32, ByVal 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. outputBlock.Text &= String.Format("{0,-33}{1,16}", ctor, decimalNum) & vbCrLf End Sub Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) outputBlock.Text &= _ "This example of the Decimal( UInt32 ) constructor " & _ vbCrLf & "generates the following output." & vbCrLf & vbCrLf outputBlock.Text &= String.Format("{0,-33}{1,16}", "Constructor", "Value") & vbCrLf outputBlock.Text &= String.Format("{0,-33}{1,16}", "-----------", "-----") & vbCrLf ' Construct Decimal objects from UInt32 values. ' UInt32.MinValue and UInt32.MaxValue are not defined in VB. CreateDecimal(outputBlock, Convert.ToUInt32(0), """UInt32.MinValue""") CreateDecimal(outputBlock, Convert.ToUInt32(4294967295), _ """UInt32.MaxValue""") CreateDecimal(outputBlock, Convert.ToUInt32(Integer.MaxValue), _ "Integer.MaxValue") CreateDecimal(outputBlock, Convert.ToUInt32(999999999), "999999999") CreateDecimal(outputBlock, Convert.ToUInt32(&H40000000), "&H40000000") CreateDecimal(outputBlock, 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
Show: