[C#] Cast Collection to List with Linq

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();

Explained:

  • TYPE is the Type of Items in the Collection.
  • mItem is an anonymous variable used to declare a single item
  • resultList is a List of type TYPE containing all items from the collection

I will not explain the basics of Lists and Collections to keep the post short.