Click here to Skip to main content
Click here to Skip to main content

Convert ArrayList to a Generic List

, 24 Mar 2010
Rate this:
Please Sign up or sign in to vote.
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 | :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 Shucks | :-\
 
(myArrayList.ToArray() as WarriorTrading.Order[]).ToList();
 
Very simple! Isn't it?

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Mahmudul Haque Azad
Software Developer (Senior) Vizrt Bangladesh
Bangladesh Bangladesh
I am truly versatile and 360 degree Engineer having wide range of development experience in .NET and Java Platform. I am also proficient in system level programming in C++. To me technology is not at all a problem, it’s the client requirement that matters! That is I am ready and comfortable to use any technology to make the business of my client a success.
 
In my five years of experience I have the opportunities to work for fortune 500 companies of US and many renowned clients from Europe.
 
My Linkedin Profile: http://bd.linkedin.com/in/mahmudazad
Follow on   Twitter

Comments and Discussions

 
GeneralMy vote of 5 PinmemberS. M. Quamruzzaman Rahmani31-May-14 21:41 
GeneralMy vote of 5 PinmemberMd. Rashidul Hasan Masum11-Jan-13 20:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 25 Mar 2010
Article Copyright 2010 by Mahmudul Haque Azad
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid