A method to realize deep copy of Hashtable
1 protected void CopyHash(Hashtable src, out Hashtable dst)
2 {
3 MemoryStream ms = new MemoryStream();
4
5 BinaryFormatter bf = new BinaryFormatter();
6
7 //serialize source to a stream
8 bf.Serialize(ms, src);
9
10 //deserialize it to the copy
11 ms.Seek(0, 0);
12
13 dst = (Hashtable)bf.Deserialize(ms);
14 }
2 {
3 MemoryStream ms = new MemoryStream();
4
5 BinaryFormatter bf = new BinaryFormatter();
6
7 //serialize source to a stream
8 bf.Serialize(ms, src);
9
10 //deserialize it to the copy
11 ms.Seek(0, 0);
12
13 dst = (Hashtable)bf.Deserialize(ms);
14 }