C# Convert ToChar(Int64)
Description
Convert ToChar(Int64)
converts the value of the specified
64-bit signed integer to its equivalent Unicode character.
Syntax
Convert.ToChar(Int64)
has the following syntax.
public static char ToChar(
long value
)
Parameters
Convert.ToChar(Int64)
has the following parameters.
value
- The 64-bit signed integer to convert.
Returns
Convert.ToChar(Int64)
method returns A Unicode character that is equivalent to value.
Example
The following example attempts to convert a long integer to a Char, and throws a OverflowException on failure.
/*from w w w.j av a 2 s . c o m*/
using System;
public class MainClass{
public static void Main(String[] argv){
long longVal = 123L;
char charVal = 'a';
charVal = System.Convert.ToChar(longVal);
System.Console.WriteLine("{0} as a char is {1}",longVal, charVal);
longVal = System.Convert.ToInt64(charVal);
System.Console.WriteLine("{0} as an Int64 is {1}",charVal, longVal);
}
}
The code above generates the following result.