应用程序常常需要在硬盘上存储数据,而逐段构建文本和数据文件不是最方便的方式。
有时最好以对象的形式存储数据。
● System.Runtime.Serialization.Formatters.Binary:这个命名空间包含了BinaryFormatter类,它能把对象串行化为二进制数据,把二进制数据串行化为对象。
● System.Runtime.Serialization.Formatters.Soap:这个命名空间包含了SoapFormatter类,它能把对象串行化为SOAP格式的XML数据,把SOAP格式的XML数据串行化为对象。
下面是一个实例,通过这个实例,我们可以就可以很清晰的认识到串行化和并行化的具体处理。
1
using System;
2
using System.Data;
3
using System.Runtime.Serialization;
4
using System.Runtime.Serialization.Formatters.Binary;
5
using System.IO;
6
using System.Text;
7
using System.Collections.Generic;
8
9
2
3
4
5
6
7
8
9