Windows apps
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.Decimal(Int32) Constructor

.NET Framework 3.0
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
)
public Decimal (
int value
)
public function Decimal (
value : int
)
Not applicable.

#### Parameters

value

The value to represent as a Decimal.

## Example

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 DecimalCtorIDemo
{
// Create a decimal object and display its value.
public static void CreateDecimal( 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.
Console.WriteLine( "{0,-30}{1,16}", ctor, decimalNum );
}

public static void Main( )
{
Console.WriteLine( "This example of the decimal( 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 int values.
CreateDecimal( int.MinValue, "int.MinValue" );
CreateDecimal( int.MaxValue, "int.MaxValue" );
CreateDecimal( 0, "0" );
CreateDecimal( 999999999, "999999999" );
CreateDecimal( 0x40000000, "0x40000000" );
CreateDecimal( 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
*/

// Example of the decimal( int ) constructor.
import System.* ;

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

public static void main(String[] args)
{
Console.WriteLine(("This example of the decimal( int ) "
+ "constructor \ngenerates the following output.\n"));
Console.WriteLine("{0,-35}{1,22}", "Constructor", "Value");
Console.WriteLine("{0,-35}{1,22}", "-----------", "-----");

// Construct decimal objects from long values.
CreateDecimal(Integer.MIN_VALUE, "int.MinValue");
CreateDecimal(Integer.MAX_VALUE, "int.MaxValue");
CreateDecimal(0, "0");
CreateDecimal(999999999, "999999999");
CreateDecimal(0x40000000, "0x40000000");
CreateDecimal(((int)0xC0000000), "(int)0xC0000000");
} //main
} //DecimalCtorLDemo

/*
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
*/

## Platforms

Windows 98, Windows Server 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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

## Version Information

#### .NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

#### .NET Compact Framework

Supported in: 2.0, 1.0

#### XNA Framework

Supported in: 1.0