直接用明文文本的方式保存对象信息不是非常科学,现在用二进制序列化的方式来保存。
这里要先增加命名空间:using System.Runtime.Serialization.Formatters.Binary;,还要给实体类增加序列化标识特性。
通过分层设计来实现:
实体类
Student.cs:
1 | using System; |
Service
StudentService.cs:
1 | using System; |
界面
Form.cs:
1 | using System; |
运行效果

直接用明文文本的方式保存对象信息不是非常科学,现在用二进制序列化的方式来保存。
这里要先增加命名空间:using System.Runtime.Serialization.Formatters.Binary;,还要给实体类增加序列化标识特性。
通过分层设计来实现:
Student.cs:
1 | using System; |
StudentService.cs:
1 | using System; |
Form.cs:
1 | using System; |

微信支付
支付宝