C#, a String\'s Split() method, how can I put the resulting string[] into an ArrayList or Stack?
If you want a re-usable method, you could write an extension method.
public static ArrayList ToArrayList(this IEnumerable enumerable) {
var list = new ArrayList;
for ( var cur in enumerable ) {
list.Add(cur);
}
return list;
}
public static Stack ToStack(this IEnumerable enumerable) {
return new Stack(enumerable.ToArrayList());
}
var list = "hello wolrld".Split(' ').ToArrayList();