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
2009-11-09 15:37:39
The lowest of low hanging fruit.
Will
2009-11-09 15:42:12
+5
A:
string[] myStringArray = new string[2];
myStringArray[0] = "G";
myStringArray[1] = "L";
ArrayList myArrayList = new ArrayList();
myArrayList.AddRange(myStringArray);
Kyle B.
2009-11-09 15:38:01
+2
A:
Hi,
System.Collections.ArrayList list = new System.Collections.ArrayList( new string[] { "a", "b", "c" } );
IordanTanev
2009-11-09 15:38:25
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áč
2009-11-09 15:39:28