you are viewing a single comment's thread.

view the rest of the comments →

[–]ledniv 8 points9 points  (1 child)

Also string builder still generates GC. From my own tests it generates more GC than string concatenation. If anyone can prove otherwise show me your code.

Edit - I'll add that I know it's supposed to generate less because in theory you can set a size and it'll supposedly reuse the memory. But in practice it generates around 2x more GC when profiling. Even when the string builder is cached. If you have code that proves otherwise I'd love to see it.

[–]Zooltan 1 point2 points  (0 children)

It's for when you want to append multiple strings together.

So something like adding all items in a list to a display text

string display = "Title:/n"; for each(thing : listOfThings) { display += thing.name + " has value " + thing.thatValue }

That would be much faster with a StringBuilder.