Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
12 events
when toggle format what by license comment
Mar 7, 2019 at 17:19 history edited Kev CC BY-SA 4.0
added 120 characters in body
Feb 7, 2016 at 17:59 history edited Markus Safar CC BY-SA 3.0
Reformatted the code
Jan 12, 2015 at 12:28 comment added Chris F Carroll 6 years later, this ain't quite so anymore. In Net4, string.Format() creates and caches a StringBuilder instance which it reuses, so it might in some test cases be faster than StringBuilder. I've put a revised benchmark in answer below (which still says that concat is fastest and for my test case, format is 10% slower than StringBuilder).
Jul 19, 2013 at 21:28 comment added Ben Collins One problem with the benchmarks on Jerry Dixon's page is that he never calls .ToString() on the StringBuilder object. Over a great many iterations, that time makes a big difference, and means that he's not quite comparing apples to apples. That's the reason he shows such great performance for StringBuilder and probably accounts for his surprise. I just repeated the benchmark correcting that mistake and got the expected results: the String + operator was fastest, followed by StringBuilder, with String.Format bringing up the rear.
Dec 8, 2011 at 11:48 history edited Kev CC BY-SA 3.0
added 9 characters in body
Aug 2, 2011 at 14:24 history edited Kev CC BY-SA 3.0
Repair link rot
Feb 24, 2011 at 22:35 history edited Kev CC BY-SA 2.5
deleted 7 characters in body
Aug 23, 2009 at 12:47 vote accept lomaxx
Aug 9, 2008 at 16:45 history edited Kev CC BY-SA 2.5
Aug 9, 2008 at 16:25 history edited Kev CC BY-SA 2.5
Added link benchmarks
Aug 9, 2008 at 16:18 history edited Kev CC BY-SA 2.5
Making the point about the importance benchmarking a little clearer.
Aug 9, 2008 at 15:57 history answered Kev CC BY-SA 2.5