If you import the System.Linq namespace, you can convert an ArrayList to a generic List by calling Cast and then ToList:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Sample
{
public static void Main()
{
ArrayList al = new ArrayList();
al.AddRange(new[] { 1, 5, 9 });
List list = al.Cast().ToList();
foreach(int i in list){
Console.WriteLine(i);
}
}
}
The output:
1
5
9