title: To ToList() or not to ToList()?
body: <p>Given an <strong>in memory</strong> (not LINQ to SQL) list of classes:</p>
  
  <pre><code>List&lt;MyClass&gt; myItems = /*lots and lots of items*/;
  </code></pre>
  
  <p>which I am grouping using a <code>GroupBy()</code> statement:</p>
  
  <pre><code>myItems.GroupBy(g =&gt; g.Ref)
  </code></pre>
  
  <p>and then immediately consuming in a <code>foreach</code> loop is there any difference in calling <code>.ToList()</code> on the "group" or should I just use an <code>IEnumerable</code>.</p>
  
  <p>So full code examples:</p>
  
  <h2>With <code>ToList()</code></h2>
  
  <pre><code>List&lt;List&lt;MyClass&gt;&gt; groupedItemsA = new List&lt;List&lt;MyClass&gt;&gt;();
  List&lt;List&lt;MyClass&gt;&gt; groupedItemsB = new List&lt;List&lt;MyClass&gt;&gt;();
  
  List&lt;MyClass&gt; myItems = /*lots and lots of items*/;
  List&lt;IGrouping&lt;string, MyClass&gt;&gt; groupedItems = myItems.GroupBy(g =&gt; g.Ref).ToList();
  foreach(IGrouping&lt;string, MyClass&gt; item in groupedItems)
  {
    if (/*check something*/)
    {
       groupedItemsA.Add(item.ToList());
    }
    else
    {
      groupedItemsB.Add(item.ToList());
    }
  }
  </code></pre>
  
  <p>or</p>
  
  <h2>Using <code>IEnumerable</code></h2>
  
  <pre><code>List&lt;List&lt;MyClass&gt;&gt; groupedItemsA = new List&lt;List&lt;MyClass&gt;&gt;();
  List&lt;List&lt;MyClass&gt;&gt; groupedItemsB = new List&lt;List&lt;MyClass&gt;&gt;();
  
  
  List&lt;MyClass&gt; myItems = /*lots and lots of items*/;
  IEnumerable&lt;IGrouping&lt;string, MyClass&gt;&gt; groupedItems = myItems.GroupBy(g =&gt; g.Ref);
  foreach(IGrouping&lt;string, MyClass&gt; item in groupedItems)
  {
    if (/*check something*/)
    {
       groupedItemsA.Add(item.ToList());
    }
    else
    {
      groupedItemsB.Add(item.ToList());
    }
  }
  </code></pre>
  
  <p>Is there any difference in the execution plan of these "under the hood"? Would either of these be more efficient or does it not really matter?</p>
  
  <p>I am <strong>not</strong> using the <code>groupedItems</code> list after this.</p>