tags:

views:

195

answers:

4

I have an array of strings. How can I convert it to System.Collections.ArrayList?

+15  A: 

Just use ArrayList's constructor:

var a = new string[100]; 
var b = new ArrayList(a);
jthg
The lowest of low hanging fruit.
Will
+5  A: 
string[] myStringArray = new string[2];
myStringArray[0] = "G";
myStringArray[1] = "L";

ArrayList myArrayList = new ArrayList();
myArrayList.AddRange(myStringArray);
Kyle B.
+2  A: 

Hi,

System.Collections.ArrayList list = new System.Collections.ArrayList( new string[] { "a", "b", "c" } );
IordanTanev
A: 

in Java you would do

new ArrayList(Arrays.asList(stringArray));

Sorry, I don't know about C#, but I'd suggest you have a look at the various ArrayList constructors and at some asList() method which would turn array to a List.

Peter Perháč