convert EnumerableRowCollection<string> to List<string>

c#, linq

Solution

Since EnumerableRowCollection<TRow> implements `IEnumerable<T>` you can just add a `ToList()` at the end:

using System.Linq;

List<string> bankCodes = ( from q in QueueData.AsEnumerable() select q.Field<string>("START") ).ToList();

or alternatively

List<string> bankCodes =  QueueData.AsEnumerable()
    .Select(r => r.Field<string>("START"))
    .ToList();

Problem

I am trying to return this collection in a function: ``` List<string> codes = ( from q in Data.AsEnumerable() select q.Field<string>("START") ); return codes; ``` This throws error: ``` Cannot implicitly convert type 'System.Data.EnumerableRowCollection<string>' to 'System.Collections.Generic.List<string>' ``` What's the best way to return such a collection?

Original source