//Binary Formatter :: Write operation public static void Main1() { FileStream fs = new FileStream("BinaryFormatter.dat", FileMode.Create); Time t1 = new Time(10, 20, 30); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fs, t1); fs.Close(); }
//Soap Formatter :: Write Operation public static void Main3() { FileStream fs = new FileStream("SoapFormatter.xml",FileMode.Create); Time t3 = new Time(10, 20, 30); SoapFormatter sf = new SoapFormatter(); sf.Serialize(fs, t3); fs.Close(); }
//Xml Formatter :: Write Operation public static void Main() { FileStream fs = new FileStream("XmlFormatter.xml",FileMode.Create); Time t5 = new Time(50,100,150); XmlSerializer xf = new XmlSerializer(typeof(Time)); xf.Serialize(fs,t5); fs.Close(); }