StringBuilder performance issues in .NET 4.0 and 4.5

I have recently discovered interesting behavior change of StringBuilder class introduced in .NET framework 4.0 (and remaining in 4.5). There is also a easy workaround once you know the behavior. Sample code exposing the problem Let’s use the following test code: static void TestStringBuilder(bool reuse) { StringBuilder sb = new StringBuilder(); Stopwatch stopWatch = new…

2