title: Why IEnumerable slow and List is fast?
body: <p>Came across this code.</p>
  <pre><code>var dic = new Dictionary&lt;int, string&gt;();
  for(int i=0; i&lt;20000; i++)
  {
      dic.Add(i, i.ToString());
  }
  
  var list = dic.Where(f =&gt; f.Value.StartsWith(&quot;1&quot;)).Select(f =&gt; f.Key);//.ToList(); //uncomment for fast results 
  Console.WriteLine(list.GetType());
  var list2 = dic.Where(f =&gt; list.Contains(f.Key)).ToList();
  Console.WriteLine(list2.Count());
  </code></pre>
  <p>So when .ToList() is commented it's slow, when not - it's fast. Reproducable <a href="http://rextester.com/SYPD34574" rel="nofollow noreferrer">here</a> How could this be explained? Should I always make everything ToList() to ensure speed (i.e. in which circumstances IEnumerable would be more preferable)? Note I'm talking only about linq to objects, I know linq to sql laziness and stuff.</p>