C# Convert ToChar(SByte)
Description
Convert ToChar(SByte)
converts the value of the specified
8-bit signed integer to its equivalent Unicode character.
Syntax
Convert.ToChar(SByte)
has the following syntax.
[CLSCompliantAttribute(false)]
public static char ToChar(
sbyte value
)
Parameters
Convert.ToChar(SByte)
has the following parameters.
value
- The 8-bit signed integer to convert.
Returns
Convert.ToChar(SByte)
method returns A Unicode character that is equivalent to value.
Example
The following example converts an array of signed bytes to Char values.
/*from ww w. java 2 s.c om*/
using System;
public class MainClass{
public static void Main(String[] argv){
sbyte[] numbers = { SByte.MinValue, -1, 40, 80, 120, SByte.MaxValue };
char result;
foreach (sbyte number in numbers)
{
try {
result = Convert.ToChar(number);
Console.WriteLine("{0} converts to '{1}'.", number, result);
}
catch (OverflowException) {
Console.WriteLine("{0} is outside the range of the Char data type.",
number);
}
}
}
}
The code above generates the following result.