tag:blogger.com,1999:blog-5822946.post112810642158125446..comments2014-09-17T10:15:34.033-05:00Comments on Marc's Musings: Samples are not the -right way- to do things.IDisposablehttp://www.blogger.com/profile/02275315449689041289noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-5822946.post-1137684331820230432006-01-19T09:25:00.000-06:002006-01-19T09:25:00.000-06:00It depends. :) In this particular case this code...It depends. :) In this particular case this code is only executed once, during initialization, and then the results are cached -- so I valued readability. But I'm still not sure how big the difference really is anyhow. The numbers I've seen from multiple independent sources is that string concatenation is faster when there are 4 or fewer strings, but once you get 5 or more strings that is not likely to be true. If your option is StringBuilder then it seems to just about always be faster once you get to 5 or more strings, while its not so clear-cut with string.Format, but even then its also not clearly better to use concatenation either. If you really need the performance, and in this case I just don't think it was necessary due to the one-time initialization, then I would switch to a StringBuilder approach at this point. Anyhow, my point isn't to say you're wrong and I'm right -- I just found the post and wanted to add another line of thought to put it into perspective.<BR/><BR/>Paul WilsonAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5822946.post-1130269299313405142005-10-25T14:41:00.000-05:002005-10-25T14:41:00.000-05:00Using it for localized sentences is exact what Str...Using it for localized sentences is exact what String.Format is for. The example was building SQL statements, which are not sentences in any form, nor are they subject to localization (unless you're doing the funky parallel tables for localize lookups trick).IDisposablehttps://www.blogger.com/profile/02275315449689041289noreply@blogger.comtag:blogger.com,1999:blog-5822946.post-1128615901130674072005-10-06T11:25:00.000-05:002005-10-06T11:25:00.000-05:00I see the first form most often thanks to the need...I see the first form most often thanks to the need to localize the strings. So people drop the {0} form into a string table and do String.Format. <BR/><BR/>Building a string in English sentence structure is asking for a bug later on...<BR/><BR/>jpsAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5822946.post-1128600012226555102005-10-06T07:00:00.000-05:002005-10-06T07:00:00.000-05:00I know what you mean, but I do think the first ver...I know what you mean, but I do think the first version is very readable. My eyes can see what string is being build and pick out the {0} placeholders easily.Anonymousnoreply@blogger.com