Decimal Constructor (Int32)

# Decimal Constructor (Int32)

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

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

## Syntax

```public Decimal(
int value
)
```

#### Parameters

value
Type: System.Int32
The value to represent as a Decimal.

## Examples

The following code example creates several Decimal numbers using the constructor overload that initializes a Decimal structure with an Int32 value.

```
// Example of the decimal( int ) constructor.
using System;

class Example
{
// Create a decimal object and display its value.
public static void CreateDecimal(System.Windows.Controls.TextBlock outputBlock, int 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.
outputBlock.Text += String.Format("{0,-30}{1,16}", ctor, decimalNum) + "\n";
}

public static void Demo(System.Windows.Controls.TextBlock outputBlock)
{
outputBlock.Text += "This example of the decimal( int ) " +
"constructor \ngenerates the following output.\n" + "\n";
outputBlock.Text += String.Format("{0,-30}{1,16}", "Constructor", "Value") + "\n";
outputBlock.Text += String.Format("{0,-30}{1,16}", "-----------", "-----") + "\n";

// Construct decimal objects from int values.
CreateDecimal(outputBlock, int.MinValue, "int.MinValue");
CreateDecimal(outputBlock, int.MaxValue, "int.MaxValue");
CreateDecimal(outputBlock, 0, "0");
CreateDecimal(outputBlock, 999999999, "999999999");
CreateDecimal(outputBlock, 0x40000000, "0x40000000");
CreateDecimal(outputBlock, unchecked((int)0xC0000000),
"(int)0xC0000000");
}
}

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

Constructor                              Value
-----------                              -----
decimal( int.MinValue )            -2147483648
decimal( int.MaxValue )             2147483647
decimal( 0 )                                 0
decimal( 999999999 )                 999999999
decimal( 0x40000000 )               1073741824
decimal( (int)0xC0000000 )         -1073741824
*/

```

## Version Information

#### Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone