The easiest way to convert an ArrayList
full of objects of type T
would be this (assuming you're using .NET 3.5 or greater):
List<T> list = arrayList.Cast<T>().ToList();
If you're using 3.0 or earlier, you'll have to loop yourself:
List<T> list = new List<T>(arrayList.Count);
foreach(T item in arrayList) list.Add(item);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…