C# BinaryWriter Write(Int64)
Description
BinaryWriter Write(Int64)
Writes an eight-byte signed
integer to the current stream and advances the stream position by eight bytes.
Syntax
BinaryWriter.Write(Int64)
has the following syntax.
public virtual void Write(
long value
)
Parameters
BinaryWriter.Write(Int64)
has the following parameters.
value
- The eight-byte signed integer to write.
Returns
BinaryWriter.Write(Int64)
method returns
Example
using System;//from w w w . j a va 2 s .c om
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((Int64)2);
}
using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
{
Console.WriteLine(reader.ReadInt64());
}
}
}
The code above generates the following result.