G
Guest
Hi,
Can a StringBuilder buffer be cleared? I'm confused. It is supposed that the StringBuilder class, can deal with all the memory allocation and deallocation needed for normal string operations (concatenations, replacements, etc.), because the String class just creates and destroys instances at an object level. I can't find a method to clear a StringBuilder object's buffer for reusing it (the idea is to avoid object instantiation/destruction, so I don't want to instantiate several StringBuilder objects).
By the way I prefer code like this:
Dim str as String
str = "->" + Value1 + "<-" + ControlChars.CrLf + "->" + Value2 + "<-" + ControlChars.CrLf
than this:
Dim str as StringBuilder
str.AppendFormat("->{0}<-",Value1)
str.AppendFormat(ControlChars.CrLf)
str.AppendFormat("->{0}<-",Value2)
str.AppendFormat(ControlChars.CrLf)
Finally I will really prefer an escape code for CrLf to be included in the Format method, that will make the use of StringBuilder almost like String. Anyway, I still have missing the Clear method in StringBuilder class...
Did I got something wrong??
Mariano.
Can a StringBuilder buffer be cleared? I'm confused. It is supposed that the StringBuilder class, can deal with all the memory allocation and deallocation needed for normal string operations (concatenations, replacements, etc.), because the String class just creates and destroys instances at an object level. I can't find a method to clear a StringBuilder object's buffer for reusing it (the idea is to avoid object instantiation/destruction, so I don't want to instantiate several StringBuilder objects).
By the way I prefer code like this:
Dim str as String
str = "->" + Value1 + "<-" + ControlChars.CrLf + "->" + Value2 + "<-" + ControlChars.CrLf
than this:
Dim str as StringBuilder
str.AppendFormat("->{0}<-",Value1)
str.AppendFormat(ControlChars.CrLf)
str.AppendFormat("->{0}<-",Value2)
str.AppendFormat(ControlChars.CrLf)
Finally I will really prefer an escape code for CrLf to be included in the Format method, that will make the use of StringBuilder almost like String. Anyway, I still have missing the Clear method in StringBuilder class...
Did I got something wrong??
Mariano.