BinaryWriter and BinaryReader classes for the writing and reading of primitive types
using System;
using System.IO;
public class Binary {
public static void Main(string [] args) {
BinaryWriter output = new BinaryWriter(new FileStream("test.dat",FileMode.Create));
output.Write(1);
output.Write(0.01);
output.Close();
BinaryReader input = new BinaryReader(new FileStream("test.dat",FileMode.Open));
Console.WriteLine("{0} ", input.ReadInt32());
Console.WriteLine("{0:F1} ", input.ReadDouble());
input.Close();
}
}
Related examples in the same category