C# BinaryWriter Write(Decimal)
Description
BinaryWriter Write(Decimal)
Writes a decimal value
to the current stream and advances the stream position by sixteen bytes.
Syntax
BinaryWriter.Write(Decimal)
has the following syntax.
public virtual void Write(
decimal value
)
Parameters
BinaryWriter.Write(Decimal)
has the following parameters.
value
- The decimal value to write.
Returns
BinaryWriter.Write(Decimal)
method returns
Example
using System;// w w w . j a v a 2 s . co 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.2M);
}
using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
{
Console.WriteLine(reader.ReadDecimal());
}
}
}
The code above generates the following result.