StringBuilder.Length property is not readonly

Published 10-07-2005 2:03 PM | jokiz

For your information, the StringBuilder's Length property is not readonly just like the String class.  It has a mutator (set counterpart) where you can set the underlying string's length which can either truncate the underlying string or pad it with spaces.  You don't have to use

myStringBuilder.Remove(0, myStringBuilder.Length)

just to reuse your stringbuilder instance, just set its Length property to 0.

myStringBuilder.Length = 0

Filed under: ,

Comments

# dehran ph said on October 13, 2005 7:44 PM:

So you track Brad Adams blog, it very nice entries. I found that topic there.

# jokiz said on October 17, 2005 9:04 PM:

hmmm, wasn't able to read this entry from his blog, found this out the hard way... :p