title: Is stringbuilder necessary anymore?
body: <p>We all know that concatenating strings can cause efficiency problems, especially in loops. I was taught to use <code>StringBuilder</code> to prevent these problems.</p>
  
  <p>So this:</p>
  
  <pre><code>str += someotherstring
  </code></pre>
  
  <p>Turns into this:</p>
  
  <pre><code>StringBuilder sb = new StringBuilder();   
  sb.AppendLine(someotherstring);
  </code></pre>
  
  <p>But it is my understanding that the CLR in the .NET framework 3.5 and later is smart enough to output the same IL for both approaches. So is there a reason I should be enforcing stringbuilder in my teams code reviews anymore?</p>
  
  <p><strong>Edit</strong>: I think <strong>Servy</strong> hit the nail on the head in the comments:</p>
  
  <blockquote>
    <p>This is the case when concatenating a number of strings <em>known</em> at compile time. Because of that, when concatenating a number of strings known at compile time there is no need to use a SB. When concatenating a number of strings <em>unknown</em> at compile time, it cannot do that</p>
  </blockquote>