Alex Rivera | Logout

Arraylist to List<t> using .Net?

Asked 2010-08-02T19:10:58.673
12

How can I convert/dump an arraylist into a list? I'm using arraylist because I'm using the ASP.NET profiles feature and it looked like a pain to store List in profiles.

Note: The other option would be to wrap the List into an own class and do away with ArrayList.

http://www.ipreferjim.com/site/2009/04/storing-generics-in-asp-net-profile-object/

Edit
Report

1 Answer

0

This works in Framework <3.5 too:

Dim al As New ArrayList()
al.Add(1)
al.Add(2)
al.Add(3)
Dim newList As New List(Of Int32)(al.ToArray(GetType(Int32)))

C#

List<int> newList = new List<int>(al.ToArray(typeof(int)));
answered 2010-08-02T19:21:26.890

Your Answer