开发者

How to convert string[] to ArrayList?

开发者 https://www.devze.com 2022-12-11 02:36 出处:网络
I have an array of st开发者_C百科rings. How can I convert it to System.Collections.ArrayList?string[] myStringArray = new string[2];

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);
     }
0

精彩评论

暂无评论...
验证码 换一张
取 消