C# Convert ToDecimal(Int16)
Description
Convert ToDecimal(Int16)
converts the value of the specified
16-bit signed integer to an equivalent decimal number.
Syntax
Convert.ToDecimal(Int16)
has the following syntax.
public static decimal ToDecimal(
short value
)
Parameters
Convert.ToDecimal(Int16)
has the following parameters.
value
- The 16-bit signed integer to convert.
Returns
Convert.ToDecimal(Int16)
method returns A decimal number that is equivalent to value.
Example
The following example converts an array of 16-bit signed integers to Decimal values.
/* w w w. j av a 2s. c om*/
using System;
public class MainClass{
public static void Main(String[] argv){
short[] numbers = { Int16.MinValue, -1000, 0, 1000, Int16.MaxValue };
decimal result;
foreach (short number in numbers)
{
result = Convert.ToDecimal(number);
Console.WriteLine("Converted the Int16 value {0} to the Decimal value {1}.",
number, result);
}
}
}
The code above generates the following result.