This documentation is archived and is not being maintained.

Convert.ToInt64 Method (Byte)

.NET Framework 1.1

Converts the value of the specified 8-bit unsigned integer to the equivalent 64-bit signed integer.

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


An 8-bit unsigned integer.

Return Value

The 64-bit signed integer equivalent to the value of value.


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

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

    Dim byteVal As Byte = 0

    ' A conversion from Long to Byte can overflow.
        byteVal = System.Convert.ToByte(longVal)
        System.Console.WriteLine("{0} as a Byte is {1}", _
                                  longVal, byteVal)
    Catch exception As System.OverflowException
        System.Console.WriteLine( _
            "Overflow in Long-to-Byte conversion.")
    End Try

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

public void ConvertLongByte(long longVal) {

    byte    byteVal = 0;

    // A conversion from Long to byte can overflow.
    try {
        byteVal = System.Convert.ToByte(longVal);
        System.Console.WriteLine("{0} as a byte is {1}",
            longVal, byteVal);
    catch (System.OverflowException) {
            "Overflow in long-to-byte conversion.");
    // A conversion from Byte to long cannot overflow.
    longVal = System.Convert.ToInt64(byteVal);
    System.Console.WriteLine("{0} as an Int64 is {1}",
        byteVal, longVal);


   void ConvertLongByte(Int64 longVal)
      Byte    byteVal = 0;

      // A conversion from Long to Byte can overflow.
      try {
         byteVal = System::Convert::ToByte(longVal);
         System::Console::WriteLine(S" {0} as a Byte is {1}",
            __box(longVal), __box(byteVal));
      } catch (System::OverflowException*) {
         System::Console::WriteLine(S"Overflow in long-to-Byte conversion.");

      // A conversion from Byte to long cannot overflow.
      longVal = System::Convert::ToInt64(byteVal);
      System::Console::WriteLine(S" {0} as an Int64 is {1}",
         __box(byteVal), __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