View Code
1 1、ArrarList 转换为 string[] :
2
3 ArrayList list = new ArrayList();
4
5 list.Add("aaa");
6
7 list.Add("bbb");
8
9 //转换成数组
10
11 string[] arrString = (string[])list.ToArray(typeof( string)) ;
12
13 2、string[] 转换为 ArrarList :
14
15 ArrayList list = new ArrayList(new string[] { "aaa", "bbb" });
16
17 3、ArrayList 转换为 string :
18
19 ArrayList list = new ArrayList();
20
21 list.Add("aaa");
22
23 list.Add("bbb");
24
25 //转换成数组
26
27 string str= string.Join(",", (string[])list.ToArray(typeof( string)));
28
29 4、string 转换为 ArrayList :
30
31 string str="1,2,3,4,5";
32
33 ArrayList b = new ArrayList( str.Split(',') ) ;