示例#1
0
        public static void Main()
        {
            FileStream      fs  = new FileStream("g:\\serial_demo.txt", FileMode.Open);
            BinaryFormatter bfm = new BinaryFormatter();
            Serialize1      sr  = (Serialize1)bfm.Deserialize(fs);

            Console.WriteLine("std_id = " + sr.std_id);
            Console.WriteLine("std_name= " + sr.std_name);
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            FileStream      fs  = new FileStream("g://serial_demo.txt", FileMode.OpenOrCreate);
            BinaryFormatter bfm = new BinaryFormatter();
            Serialize1      sr  = new Serialize1(500, "Jason Stathon");

            bfm.Serialize(fs, sr);
            fs.Close();
            Console.WriteLine("Serialization is done!");
            Console.ReadLine();
        }