C# BinaryReader ReadUInt64

Description

BinaryReader ReadUInt64 Reads an 8-byte unsigned integer from the current stream and advances the position of the stream by eight bytes.

Syntax

BinaryReader.ReadUInt64 has the following syntax.


[CLSCompliantAttribute(false)]
public virtual ulong ReadUInt64()

Returns

BinaryReader.ReadUInt64 method returns An 8-byte unsigned integer read from this stream.

Example


using System;/*from  w  w w.j a  v a2s . c  o m*/
using System.IO;

class ConsoleApplication
{
    const string fileName = "data.dat";

    static void Main()
    {
        using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
        {
            writer.Write((UInt64)123);
        }
        using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
        {
            Console.WriteLine(reader.ReadUInt64());
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter