Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Decimal Constructor (UInt32)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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)

public Decimal(
	uint 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( 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

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2018 Microsoft