This is just because I am curious about everything.I was looking at a VB disassembly of the StringBuilder.CopyTo method using .NET Reflector 6, and a portion of it (its last part, actually) showed this:If (count <> 0) Then DimchRefAsChar* FixedchRef=AddressOf destination(destinationIndex) Dimstr2AsChar* Fixedstr2=DirectCast(threadSafeString, Char*)
Last modified by DavidRossG on 7/18/2010 3:13:36 PM
I've noticed this method has fairly high CPU utilization compared to an implementation that relies completely on strings. I guessed this may be due to the StringBuilder memory buffer growing continuously, but setting a fixed value for capacity has no effect. My platform is WINCE 6.
Has anyone else noticed poor performance behavior using this method?
Last modified by RoyaleFlan on 1/11/2010 4:53:56 PM
To effectively clear your stringbuilder without destroying it use:
someStringBuilder.length = 0;
someStringBuilder.capacity = 0;
This destroys both its contents and resizes it to zero.
As noted above clear the size can impact smaller applications.
Added benefit: If your application support a very large number of users (i.e. Microsoft's Sites like Live.com) this will ensure the most e
Last modified by Mr. Davies on 11/12/2008 10:44:16 PM
I wrote a detailed 2-part analysis of StringBuilder vs string concatenation here http://www.chinhdo.com/chinh/blog/20070224/stringbuilder-is-not-always-faster/
Last modified by Chinh Do on 10/11/2007 1:15:58 AM