C# BitConverter ToUInt64
Description
BitConverter ToUInt64
returns a 64-bit unsigned integer
converted from eight bytes at a specified position in a byte array.
Syntax
BitConverter.ToUInt64
has the following syntax.
[CLSCompliantAttribute(false)]/*from w w w .java 2 s. c om*/
public static ulong ToUInt64(
byte[] value,
int startIndex
)
Parameters
BitConverter.ToUInt64
has the following parameters.
value
- An array of bytes.startIndex
- The starting position within value.
Returns
BitConverter.ToUInt64
method returns A 64-bit unsigned integer formed by the eight bytes beginning at startIndex.
Example
The following code example converts elements of Byte arrays to UInt64 values with the ToUInt64 method.
using System;//from w ww . j a v a2s .co m
class BytesToUInt64Demo
{
public static void Main( )
{
byte[ ] bytes = {
255, 255, 255, 0, 0, 0, 0, 0, 0, 0,
170, 170, 170, 170, 170, 0, 0, 232, 137, 4,
35, 199, 138, 255, 255, 255, 255, 255, 255, 255,
255, 127 };
ulong value = BitConverter.ToUInt64( bytes, 2 );
Console.WriteLine(value );
}
}
The code above generates the following result.