如何将string []转换为ArrayList?

时间:2009-11-09 15:35:42

标签: c# .net

我有一个字符串数组。如何将其转换为System.Collections.ArrayList?

4 个答案:

答案 0 :(得分:37)

只需使用ArrayList的构造函数:

var a = new string[100]; 
var b = new ArrayList(a);

答案 1 :(得分:37)

string[] myStringArray = new string[2];
myStringArray[0] = "G";
myStringArray[1] = "L";

ArrayList myArrayList = new ArrayList();
myArrayList.AddRange(myStringArray);

答案 2 :(得分:3)

System.Collections.ArrayList list = new System.Collections.ArrayList(new string [] {“a”,“b”,“c”});

答案 3 :(得分:1)

public stringList[] = {"one", "two", "three"};
public ArrayList myArrayList;

     myArrayList = new ArrayList();
     foreach (string i in stringList)
     {
         myArrayList.Add(i);
     }