u/BigOnLognin r/dotnet • Recommends
On “StringBuilder the trick you didn't know”
That's an interesting quirk of StringBuilder. I'm actually quite horrified that Length is a getter AND setter. Jon Skeet has a nice link to this video about all the weird things possible with (and weird ways to break) C#.
But, as someone who has to read and fix code like this on a daily basis, no one should ever do this. This post's title should be: Look at this weird thing StringBuilder can do. DO NOT DO THIS, EVER!
Just use `string.Join` or `FormUrlEncodedContent` (if you're building a query string). It's easier to reason about and you don't need to know the internals of StringBuilder to understand.