This documentation is archived and is not being maintained.

Convert.ToInt64 Method (Char)

.NET Framework 1.1

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

[Visual Basic]
Overloads Public Shared Function ToInt64( _
   ByVal value As Char _
) As Long
public static long ToInt64(
 char value
public: static __int64 ToInt64(
 __wchar_t value
public static function ToInt64(
   value : Char
) : long;


A Unicode character.

Return Value

The 64-bit signed integer equivalent to value.


[Visual Basic, C#, C++] The following code sample illustrates the conversion of a Char value to an Int64, using ToInt64.

[Visual Basic] 
Public Sub ConvertLongChar(ByVal longVal As Long)

    Dim charVal As Char = "a"c

        charVal = System.Convert.ToChar(longVal)
        System.Console.WriteLine("{0} as a char is {1}", _
                                  longVal, charVal)
    Catch exception As System.OverflowException
        System.Console.WriteLine( _
            "Overflow in Long-to-Char conversion.")
    End Try

    ' A conversion from Char to Long cannot overflow.
    longVal = System.Convert.ToInt64(charVal)
    System.Console.WriteLine("{0} as a Long is {1}", _
                              charVal, longVal)
End Sub

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) {
            "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);


   void ConvertLongChar(Int64 longVal)
      Char    charVal = 'a';

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

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Convert Class | Convert Members | System Namespace | Convert.ToInt64 Overload List