How to convert string[] to ArrayList?
I have an array of st开发者_C百科rings. How can I convert it to System.Collections.ArrayList?
string[] myStringArray = new string[2];
myStringArray[0] = "G";
myStringArray[1] = "L";
ArrayList myArrayList = new ArrayList();
myArrayList.AddRange(myStringArray);
Just use ArrayList's constructor:
var a = new string[100];
var b = new ArrayList(a);
System.Collections.ArrayList list = new System.Collections.ArrayList( new string[] { "a", "b", "c" } );
public stringList[] = {"one", "two", "three"};
public ArrayList myArrayList;
myArrayList = new ArrayList();
foreach (string i in stringList)
{
myArrayList.Add(i);
}
精彩评论