title: C# List<T> vs IEnumerable<T> performance question
body: <p>Hi suppose these 2 methods:</p>
  
  <pre><code>private List&lt;IObjectProvider&gt; GetProviderForType(Type type)
          {
              List&lt;IObjectProvider&gt; returnValue = new List&lt;IObjectProvider&gt;();
  
              foreach (KeyValuePair&lt;Type, IObjectProvider&gt; provider in _objectProviders)
              {
                  if ((provider.Key.IsAssignableFrom(type) ||
                      type.IsAssignableFrom(provider.Key)) &amp;&amp;
                      provider.Value.SupportsType(type))
                  {
                      returnValue.Add(provider.Value);
                  }
              }
              return returnValue;
          }
  
  private IEnumerable&lt;IObjectProvider&gt; GetProviderForType1(Type type)
          {
              foreach (KeyValuePair&lt;Type, IObjectProvider&gt; provider in _objectProviders)
                  if ((provider.Key.IsAssignableFrom(type) ||
                      type.IsAssignableFrom(provider.Key)) &amp;&amp;
                      provider.Value.SupportsType(type))
  
                      yield return provider.Value;              
          }
  </code></pre>
  
  <p>Which one is quicker? When I look at the first method, I see that the memory is allocated for List, what in my opinion it's not needed. The <strong>IEnumerable</strong> method seems to be quicker to me.</p>
  
  <p>For instance, suppose you call </p>
  
  <pre><code>int a = GetProviderForType(myType).Count;
  int b = GetProviderForType1(myType).Count();
  </code></pre>
  
  <p>Now, another issue is, is there a performance difference between these 2 above?</p>
  
  <p>What do you think?</p>