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