Convert.ToInt64 Method (Char)

Converts the value of the specified Unicode character to the equivalent 64-bit signed integer.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static long ToInt64 (
	char value
)
public static long ToInt64 (
	char value
)
public static function ToInt64 (
	value : char
) : long

Parameters

value

A Unicode character.

Return Value

The 64-bit signed integer equivalent to value.

The following code sample illustrates the conversion of a Char value to an Int64, using ToInt64.

public void ConvertLongChar(long longVal) {

    char    charVal = 'a';

    try {
        charVal = System.Convert.ToChar(longVal);
        System.Console.WriteLine("{0} as a char is {1}",
            longVal, charVal);
    } 
    catch (System.OverflowException) {
        System.Console.WriteLine(
            "Overflow in long-to-char conversion.");
    }
    
    // A conversion from Char to long cannot overflow.
    longVal = System.Convert.ToInt64(charVal);
    System.Console.WriteLine("{0} as an Int64 is {1}",
        charVal, longVal);
}

public void ConvertLongChar(long longVal)
{
    char charVal = 'a';

    try {        
        charVal = System.Convert.ToChar(longVal);
        System.Console.WriteLine("{0} as a char is {1}", 
            System.Convert.ToString(longVal), 
            System.Convert.ToString(charVal));
    }
    catch (System.OverflowException exp) {        
        System.Console.WriteLine("Overflow in long-to-char conversion.");
    }

    // A conversion from Char to long cannot overflow.
    longVal = System.Convert.ToInt64(charVal);
    System.Console.WriteLine("{0} as an Int64 is {1}", 
        System.Convert.ToString(charVal), 
        System.Convert.ToString(longVal));
} //ConvertLongChar

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show: