C# Decimal Explicit(Decimal to Int16)
Description
Decimal Explicit(Decimal to Int16)
defines an explicit
conversion of a Decimal to a 16-bit signed integer.
Syntax
Decimal.Explicit(Decimal to Int16)
has the following syntax.
public static explicit operator short (
decimal value
)
Parameters
Decimal.Explicit(Decimal to Int16)
has the following parameters.
value
- The value to convert.
Returns
Decimal.Explicit(Decimal to Int16)
method returns A 16-bit signed integer that represents the converted Decimal.
Example
The following example converts Decimal numbers to Int16 values by using the explicit Decimal to Int16 conversion.
using System;//from w w w .j a v a2s. co m
class MainClass
{
public static void Main( )
{
object Int16Value;
object UInt16Value;
Int16Value = (short)123.999M;
UInt16Value = (ushort)123.999M;
Console.WriteLine(Int16Value);
Console.WriteLine(UInt16Value );
}
}
The code above generates the following result.