Convert ArrayList to a Generic List






4.71/5 (7 votes)
There is a short cut way to convert ArrayList to a generic list instead of looping through items.Generally this is what people do :omg: List orders = new List(myArrayList.count); foreach (WarriorTrading.Order order in myArrayList) { orders.add(order); }But this...
There is a short cut way to convert ArrayList to a generic list instead of looping through items.
Generally this is what people do :omg:
List orders = new List(myArrayList.count);
foreach (WarriorTrading.Order order in myArrayList)
{
orders.add(order);
}
But this can be done in single line by this :-\
(myArrayList.ToArray() as WarriorTrading.Order[]).ToList();
Very simple! Isn't it?