C# BitConverter ToInt64
Description
BitConverter ToInt64
returns a 64-bit signed integer
converted from eight bytes at a specified position in a byte array.
Syntax
BitConverter.ToInt64
has the following syntax.
public static long ToInt64(
byte[] value,
int startIndex
)
Parameters
BitConverter.ToInt64
has the following parameters.
value
- An array of bytes.startIndex
- The starting position within value.
Returns
BitConverter.ToInt64
method returns A 64-bit signed integer formed by eight bytes beginning at startIndex.
Example
The following code example converts elements of Byte arrays to Int64 values with the ToInt64 method.
// www. j a va2 s.c o m
using System;
class BytesToInt64Demo
{
public static void Main( )
{
byte[ ] bytes = {
255, 255, 255, 255, 1, 0, 0, 255, 255, 255,
255, 255, 255, 255, 127, 86, 85, 85, 85, 85,
88, 76, 73, 31, 242 };
long value = BitConverter.ToInt64( bytes, 3 );
Console.WriteLine(value );
}
}
The code above generates the following result.