C# BinaryWriter Write(Double)

Description

BinaryWriter Write(Double) Writes an eight-byte floating-point value to the current stream and advances the stream position by eight bytes.

Syntax

BinaryWriter.Write(Double) has the following syntax.


public virtual void Write(
  double value
)

Parameters

BinaryWriter.Write(Double) has the following parameters.

  • value - The eight-byte floating-point value to write.

Returns

BinaryWriter.Write(Double) method returns

Example


using System;/*w  w w.ja va 2 s  .  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(1.2D);
        }

        using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
        {
            Console.WriteLine(reader.ReadDouble());
        }
    }
}

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