Binary Writer Serialize - CSharp System.IO

CSharp examples for System.IO:BinaryWriter

Description

Binary Writer Serialize

Demo Code


using System.Text;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;/*from  ww  w  .  j av  a  2s . co  m*/
using System.Globalization;
using System;

public class Main{
  public static void Serialize(BinaryWriter binaryWriter, object objectToSend)
   {
      BinaryFormatter binaryFormatter = new BinaryFormatter();
      binaryFormatter.Serialize(binaryWriter.BaseStream, objectToSend);
   }
  public static void Serialize(Stream stream, object objectToSend)
   {
      BinaryFormatter binaryFormatter = new BinaryFormatter();
      binaryFormatter.Serialize(stream, objectToSend);
   }
}

Related Tutorials