title: Is there a more efficient way to convert LINQ result to string[] or List<string>?
body: <p>I'm looking for a way to convert the result of my Linq query to a string[] or List without the usual loop method.  In case you are wondering "Examples are fine, but what are you really trying to do?" I'm trying to do what the example shows; I have a collection of objects and I want a string array or list of the unique IDs that are contained within the list of objects.</p>
  
  <p>I think the code example says it all.  It's a complete program you can run.</p>
  
  <pre><code>using System.Collections.Generic;
  using System.Linq;
  
  class Program
  {
      class DataModel
      {
          public DataModel(string id) { ID = id; }
          public string ID;
      }
  
      static void Main(string[] args)
      {
          var dummyData = new DataModel[]
          {
              new DataModel("1"),
              new DataModel("1"),
              new DataModel("2"),
              new DataModel("3"),
              new DataModel("3")
          };
  
          //  This works fine
          var uniqueIDs = 
              from model in dummyData
              group model by model.ID into grouped
              select grouped.Key;
  
          //  This is the part that bugs me, it's so inelegant...
          List&lt;string&gt; idStringList = new List&lt;string&gt;();
          foreach (var id in uniqueIDs)
              idStringList.Add(id);
      }
  }
  </code></pre>