Question

Possible Duplicate:
best way to clear contents of .NET’s StringBuilder

Is there a quick and easy way to get rid of what a StringBuilder currently holds?

I was looking for a Clear() method but I can't find it. ;)

I would to do

stringBuilderObject = ""

or something along those lines.

Was it helpful?

Solution

stringBuilderObject.Remove(0, stringBuilderObject.Length)

OTHER TIPS

This will do it

stringBuilderObject.Length = 0;
stringBuilderObject = new StringBuilder();  // Let the GC do its job

This should do it ;)

myStringBuilder = new StringBuilder();
stringBuilderObject.Remove(0,stringBuilderObject.Length)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top