C#二进制序列化
来源:http://blog.csdn.net/mypc2010/article/details/8068963
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.Serialization.Formatters.Binary; using System.IO; namespace 二进制序列化 { class Program { static void Main(string[] args) { People p = new People(); p.Name = "许嵩"; p.Age = 28; BinaryFormatter bf = new BinaryFormatter(); FileStream fs = new FileStream("person.bin", FileMode.Create); bf.Serialize(fs,p); } } [Serializable] class People { string name; public string Name { get { return name; } set { name = value; } } int age; public int Age { get { return age; } set { age = value; } } } }