private ArrayList ObjectToArraylist(object[] coll) { ArrayList al = new ArrayList() for (int i = 0; i < coll.Length; i++) al.Add(coll[i]); return al; }
note that this is adhockly coded, and so untested, but this is what I'ld try.
as far as I know the array doesn't implment System.Collections.ICollection, so you can't initialize the arrayList automatically
You can get an array, but you can't do this automatically I believe - however, this is just my opinion that it isn't possible, and that you would have to loop through and add each item.
convert object[] to ArrayList? (C#)
DarcyThomas
Yes, it does. So you can just use:
object[] o = ...
ArrayList a = new ArrayList(o);
JACorona
private ArrayList ObjectToArraylist(object[] coll)
{
ArrayList al = new ArrayList()
for (int i = 0; i < coll.Length; i++)
al.Add(coll[i]);
return al;
}
note that this is adhockly coded, and so untested, but this is what I'ld try.
avidal
You can get an array, but you can't do this automatically I believe - however, this is just my opinion that it isn't possible, and that you would have to loop through and add each item.
Very interesting question...