title: Performance impact of changing to generic interfaces
body: <p>I work on applications developed in C#/.NET with Visual Studio. Very often ReSharper, in the prototypes of my methods, advises me to replace the type of my input parameters with more generic ones. For instance, List&lt;> with IEnumerable&lt;> if I only use the list with a foreach in the body of my method. I can understand why it looks smarter to write that but I'm quite concerned with the performance. I fear that the performance of my apps will decrease if I listen to ReSharper...</p>
  
  <p>Can someone explain to me precisely (more or less) what's happening behind the scenes (i.e. in the CLR) when I write:</p>
  
  <pre><code>public void myMethod(IEnumerable&lt;string&gt; list)
  {
    foreach (string s in list)
    {
      Console.WriteLine(s);
    }
  }
  
  static void Main()
  {
    List&lt;string&gt; list = new List&lt;string&gt;(new string[] {"a", "b", "c"});
    myMethod(list);
  }
  </code></pre>
  
  <p>and what is the difference with:</p>
  
  <pre><code>public void myMethod(List&lt;string&gt; list)
  {
    foreach (string s in list)
    {
      Console.WriteLine(s);
    }
  }
  
  static void Main()
  {
    List&lt;string&gt; list = new List&lt;string&gt;(new string[] {"a", "b", "c"});
    myMethod(list);
  }
  </code></pre>