Yesterday, Bill Wagner (author of a number of excellent books on C#) wrote a post on string concatenation, string.Format, and StringBuilder. I found it a useful update to what I previously understood. I’d written a brief post on string.Format 7 (!) years ago, and at that time I thought string.Concat (a.k.a. “blah blah blah” + “blah blah blah”) shouldn’t ever be used because of the immutability of strings meant a new string was created for each concatenation operation. Wagner touches on what operations create objects that will need to be garbage collected, as well as providing an example of when string.Concat is actually ok.
(h/t The Morning Brew)