using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
....
...
Hashtable aa = new Hashtable();
private void buttonSave_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream("e:\\aa.dat", FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, aa);
fs.Close();
}
private void buttonLoad_Click(object sender, EventArgs e)
{
aa.Clear();
FileStream fs = new FileStream("e:\\aa.dat", FileMode.OpenOrCreate);
BinaryFormatter bf = new BinaryFormatter();
aa = (Hashtable)bf.Deserialize(fs);
fs.Close();
}C# Hashtable的序列化(保存和读取)
最新推荐文章于 2020-05-07 19:58:22 发布
本文介绍了一个简单的C#应用程序,该程序演示了如何使用BinaryFormatter进行Hashtable对象的序列化和反序列化操作。通过FileStream将Hashtable对象写入磁盘文件,并从文件中读取回来。
774

被折叠的 条评论
为什么被折叠?



