This documentation is archived and is not being maintained.

# Decimal Widening Conversion (Int16 to Decimal)

Visual Studio 2010

Converts a 16-bit signed integer to a Decimal.

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

## Syntax

```'Declaration
Public Shared Widening Operator CType ( _
value As Short _
) As Decimal
```

#### 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.
Imports System
Imports Microsoft.VisualBasic

Module DecimalFromInt16Demo

Const formatter As String = _
"{0,16}{1,15}{2,10:X8}{3,9:X8}{4,9:X8}{5,9:X8}"

' Convert the Short argument and display the Decimal value.
Sub DecimalFromInt16( argument As Short )

Dim decValue    As Decimal
Dim bits( )     As Integer

' The compiler invokes a constructor in Visual Basic
' unless op_Implicit is explicitly called.
decValue = Decimal.op_Implicit( 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 ) )
End Sub

Sub Main( )

Console.WriteLine( _
"This example of the op_Implicit conversion from " & _
"Short to Decimal generates the " & vbCrLf & _
"following output. It displays the Decimal value " & _
"and its binary representation." & vbCrLf )
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( Short.MinValue )
DecimalFromInt16( Short.MaxValue )
DecimalFromInt16( &HFFF )
DecimalFromInt16( 12345 )
DecimalFromInt16( -10000 )
End Sub
End Module

' 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.