title: System.Linq.Enumerable+d__3a`1[System.String] error in LINQ foreach loop
body: <p>I have a list that I am trying to populate from another list in which I want to combine some data and eliminate some. </p>
  
  <p>In the original list the data looks like this: </p>
  
  <pre><code> Id     Text      Description
  
    1      Apple     Red Delicious
    1      Apple     Green
    1      Apple     Granny 
    2      Tomato    Roma
    2      Tomato    Cherry   
  </code></pre>
  
  <p>I want to condense this information in the second list to look like this: </p>
  
  <pre><code>  Id    Text     Description
    1     Apple    Red Delicious, Green, Granny
    2     Tomato   Roma, Cherry 
  </code></pre>
  
  <p>My class object is declared like this: </p>
  
  <pre><code> [Serializable]
   public class Food
   {
       public int Id { get;set; }
       public string Text { get;set; }
       public string Description { get;set; } 
   }
  </code></pre>
  
  <p>So I want to loop through the old list and this is how I'm trying to do it in the code: </p>
  
  <pre><code>var ids = oldList.Select(i =&gt; i.Id).Distinct(); //get distinct list of ids (e.g. 1,2)
  List&lt;Food&gt; newList = ids.Select(i =&gt; new Food(){
     Id = i,
     Text = oldList.Where(o =&gt; o.Id == i).Select(o =&gt; o.Text).Take(1).ToString(),
     Description = string.Join(",", oldList.Where(o =&gt; o.Id == i).Select(o =&gt; o.Description).ToString())
  }).ToList();
  </code></pre>
  
  <p>Right now I'm getting the System.Linq.Enumerable+d__3a`1[System.String] error because of .Take(), but if I change it just .ToString(), I get a slightly different error but from the same source System.linq.Enumerable, if I do FirstOrDefault() same thing, .Distinct() same thing. </p>
  
  <p>I think I understand that the problem is that for Text and Description its returning IEnumerable for Text and Description so I'm not getting the actual values that I want and I'm not sure I understand how to correctly convert it .ToList(). What is the correct way to access these values? </p>