C# Convert ToChar(UInt16)
Description
Convert ToChar(UInt16)
converts the value of the specified
16-bit unsigned integer to its equivalent Unicode character.
Syntax
Convert.ToChar(UInt16)
has the following syntax.
[CLSCompliantAttribute(false)]
public static char ToChar(
ushort value
)
Parameters
Convert.ToChar(UInt16)
has the following parameters.
value
- The 16-bit unsigned integer to convert.
Returns
Convert.ToChar(UInt16)
method returns A Unicode character that is equivalent to value.
Example
The following example converts each element in an array of unsigned 16-bit integers to a Char value.
// w w w. j a v a 2 s .c o m
using System;
public class MainClass{
public static void Main(String[] argv){
ushort[] numbers = { UInt16.MinValue, 40, 160, 255, 1028,
2011, UInt16.MaxValue };
char result;
foreach (ushort number in numbers)
{
result = Convert.ToChar(number);
Console.WriteLine("{0} converts to '{1}'.", number, result);
}
}
}
The code above generates the following result.