Sometimes it is better to work with a List than a collection, but how to cast if only a collection is available?
And to keep it short, how to accomplish that with Linq?
The answer is simple:
var resultList = (from TYPE mItem in originCollection select mItem).ToList();
TYPEis the Type of Items in the Collection.
mItemis an anonymous variable used to declare a single item
resultListis a List of type
TYPEcontaining all items from the collection
I will not explain the basics of Lists and Collections to keep the post short.
Subscribe to robsCode
Get the latest posts delivered right to your inbox