1![]()
2
[Serializable]
3
public class Info
4
{
5
public string name;
6
public string age;
7
}
8![]()
9
private string Serialize()
10
{
11
ArrayList al = new ArrayList();
12
Info a1 = new Info();
13
a1.name ="a";
14
a1.age ="a";
15![]()
16
Info b1 = new Info();
17
b1.name ="a";
18
b1.age ="a";
19![]()
20
al.Add(a1);
21
al.Add(b1);
22![]()
23
BinaryFormatter br = new BinaryFormatter();
24
MemoryStream ms = new MemoryStream();
25
br.Serialize(ms,al);
26
_resultbyte = ms.ToArray();
27
_resultstr = Convert.ToBase64String(_resultbyte,0,_resultbyte.Length);
28
ms.Close();
29
30
}
31![]()
32
private void Deserialize(string _resultbyte)
33
{
34
byte[] bb = Convert.FromBase64String(_resultstr);
35
MemoryStream aa = new MemoryStream(bb);
36
BinaryFormatter br = new BinaryFormatter();
37
ArrayList tes = (ArrayList)br.Deserialize(aa);
38
39
}
40![]()
41
42![]()

2
[Serializable]3
public class Info4
{5
public string name;6
public string age;7
}8

9
private string Serialize()10
{11
ArrayList al = new ArrayList();12
Info a1 = new Info();13
a1.name ="a";14
a1.age ="a";15

16
Info b1 = new Info();17
b1.name ="a";18
b1.age ="a";19

20
al.Add(a1);21
al.Add(b1);22

23
BinaryFormatter br = new BinaryFormatter();24
MemoryStream ms = new MemoryStream();25
br.Serialize(ms,al); 26
_resultbyte = ms.ToArray();27
_resultstr = Convert.ToBase64String(_resultbyte,0,_resultbyte.Length);28
ms.Close();29
30
}31

32
private void Deserialize(string _resultbyte)33
{ 34
byte[] bb = Convert.FromBase64String(_resultstr);35
MemoryStream aa = new MemoryStream(bb);36
BinaryFormatter br = new BinaryFormatter();37
ArrayList tes = (ArrayList)br.Deserialize(aa);38
39
}40

41
42

