当前位置:首页 > Windows程序 > 正文

C#中的二进制序列化和Json序列化

2021-05-26 Windows程序

BinaryFormatter bf = new BinaryFormatter(); Person p = null; using (FileStream fsWrite=new FileStream("person.bin",FileMode.Create,FileAccess.Write)) { if (ckbIsCar.Checked) { var strCarNum = txtCarNum.Text.Trim(); var strCarType = txtCarType.Text.Trim(); Car c1=new Car(strCarType,strCarNum); p = new Person(strName, intAge,strSex, strEmail, strPhone, strAddress, c1); } else { //不登记车的情况 p = new Person(strName, intAge,strSex, strEmail, strPhone, strAddress, null); } //二进制序列化 bf.Serialize(fsWrite, p); MessageBox.Show("对象序列化完毕");

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/71304.html