C# strings

  • Thread starter Thread starter Trevor
  • Start date Start date
It absolutely will be. I HAVE tested it and posted about it previously.
Even for several += concatenations it is faster if the quantity is small
enough. One thing I saw is that you have to consider not only the number of
throwaway objects created, but also the size of them, as the performance
differences are directly correlated to the garbage collection that takes
place. That is, I think the frequency of the GC being "triggered" is
important as well as the number of objects it has to dispose of when it is.

When it's all said and done I actually prefer string.format() which is
definitely slower than both of them, but man it makes code that is so much
nicer IMO. (And as I often argue, the performance difference we're talking
about for a single build of a string is mere milliseconds - usually
completely irrelevant.)
 
Back
Top