开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜