Implicit Conversion (Int16 to Decimal)

# Decimal Implicit Conversion (Int16 to Decimal)

.NET Framework 4

Converts a 16-bit signed integer to a Decimal.

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

## Syntax

```static implicit operator Decimal (
short value
)
```

#### Parameters

value
Type: System::Int16
The16-bit signed integer to convert.

#### Return Value

Type: System::Decimal
The converted 16-bit signed integer.

## Examples

The following code example converts Int16 values to Decimal numbers using the Int16 to Decimal conversion. This conversion is implicit in C#, but requires the op_Implicit operator in Visual Basic and C++. Implicit conversions to Decimal use other methods in these languages.

```
// Example of the op_Implicit conversion from short to Decimal.
using namespace System;
#define formatter "{0,14}{1,15}{2,10:X8}{3,9:X8}{4,9:X8}{5,9:X8}"

// Convert the short argument and display the Decimal value.
void DecimalFromInt16( short argument )
{
Decimal decValue;
array<Int32>^bits;

// The compiler invokes a constructor in the Managed Extensions
// for C++ unless op_Implicit is explicitly called.
decValue = argument;

// Display the Decimal and its binary representation.
bits = Decimal::GetBits( decValue );
Console::WriteLine( formatter, argument, decValue, bits[ 3 ], bits[ 2 ], bits[ 1 ], bits[ 0 ] );
}

int main()
{
Console::WriteLine( "This example of the op_Implicit conversion from "
"short to Decimal \ngenerates the following output. "
"It displays the Decimal value \nand its binary "
"representation.\n" );
Console::WriteLine( formatter, "short argument", "Decimal value", "bits[3]", "bits[2]", "bits[1]", "bits[0]" );
Console::WriteLine( formatter, "--------------", "-------------", "-------", "-------", "-------", "-------" );

// Convert short values and display the results.
DecimalFromInt16( Int16::MinValue );
DecimalFromInt16( Int16::MaxValue );
DecimalFromInt16( 0xFFF );
DecimalFromInt16( 12345 );
DecimalFromInt16(  -10000 );
}

/*
This example of the op_Implicit conversion from short to Decimal
generates the following output. It displays the Decimal value
and its binary representation.

short argument  Decimal value   bits[3]  bits[2]  bits[1]  bits[0]
--------------  -------------   -------  -------  -------  -------
-32768         -32768  80000000 00000000 00000000 00008000
32767          32767  00000000 00000000 00000000 00007FFF
4095           4095  00000000 00000000 00000000 00000FFF
12345          12345  00000000 00000000 00000000 00003039
-10000         -10000  80000000 00000000 00000000 00002710
*/

```

## Version Information

#### .NET Framework

Supported in: 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

## Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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