C# .NET - convert arraylist to List - Asked By mostafa hamdy on 29-Feb-12 03:17 AM

Hello all
I have some C# program and I use some library class which return an arraylist of employee object  but I want to convert this arraylist to Generic List<employee> is there's any way to do that simply , please if any body get what I mean and can help me please send me or tell me about some URL may help me in doing that
regards
Mostafa
Reena Jain replied to mostafa hamdy on 29-Feb-12 03:20 AM
Hi,

There are many other things which serve you same purpose but with some different and more functionalities like List,ArrayList etc

List<string> lst = new List<string>();
lst.Add('xyz');
lst.Add('abc');

There are arraylist as well...it all depends on your purpose, and if you are using LINQ than your dynamic content inside list can be directly converted to array as you want like following

var arrayLst = (from item in lst select item).ToAray();

hope this will help you
kalpana aparnathi replied to mostafa hamdy on 29-Feb-12 03:35 AM
hi,

http://www.dotnetperls.com/convert-arraylist-list for converting arraylist to list with explanation and example.

Regards
Somesh Yadav replied to mostafa hamdy on 29-Feb-12 03:40 AM
Hi,

refer to the below link clearly explained with an examples of convert arraylist to List.

http://revenmerchantservices.com/post/c-convert-array-to-list.aspx

Hope it helps you.