C# Convert ToDecimal(SByte)
Description
Convert ToDecimal(SByte)
converts the value of the specified
8-bit signed integer to the equivalent decimal number.
Syntax
Convert.ToDecimal(SByte)
has the following syntax.
[CLSCompliantAttribute(false)]
public static decimal ToDecimal(
sbyte value
)
Parameters
Convert.ToDecimal(SByte)
has the following parameters.
value
- The 8-bit signed integer to convert.
Returns
Convert.ToDecimal(SByte)
method returns A decimal number that is equivalent to value.
Example
The following example converts each element in an array of signed bytes to a Decimal value.
/* w w w .j a v a 2 s.co m*/
using System;
public class MainClass
{
public static void Main(String[] argv)
{
sbyte[] numbers = { SByte.MinValue, -123, 0, 17, SByte.MaxValue };
decimal result;
foreach (sbyte number in numbers)
{
result = Convert.ToDecimal(number);
Console.WriteLine("Converted the SByte value {0} to {1}.", number, result);
}
}
}
The code above generates the following result.