Memory fragmentation when concatenating or adding strings but not with string.Format?
<p>So a professor in university just told me that using concatenation on strings in C# (i.e. when you use the plus sign operator) creates memory fragmentation, and that I should use <code>string.Format</code> instead.</p>

<p>Now, I've searched a lot in stack overflow and I found <strong>a lot</strong> of threads about performance, which concatenating strings win hands down. (Some of them include <a href="https://stackoverflow.com/questions/16432/string-output-format-or-concat-in-c">this</a>, <a href="https://stackoverflow.com/questions/6785/is-string-format-as-efficient-as-stringbuilder">this</a> and <a href="http://jacksondunstan.com/articles/3015" rel="nofollow noreferrer">this</a>)</p>

<p>I can't find someone who talks about memory fragmentation though. I opened .NET's <code>string.Format</code> using ILspy and apparently it uses <em>the same</em> string builder than the <code>string.Concat</code> method does (which if I understand is what the <code>+</code> sign is overloaded to). In fact: it uses the code in <code>string.Concat</code>!</p>

<p>I found <a href="http://geertverhoeven.blogspot.ca/2007/01/what-is-so-bad-about-string.html" rel="nofollow noreferrer">this article from 2007</a> but I doubt it's accurate today (or ever!). Apparently the compiler is smart enough to avoid that today, cause I can't seem to reproduce the issue. Both adding strings with string.format and plus signs end up using the same code internally. As said before, the string.Format uses the same code string.Concat uses.</p>

<p>So now I'm starting to doubt his claim. Is it true?</p>