M
moondaddy
Using c# 3.5, what's the best way to remove the contents of a stringbuilder
object? I was using this code:
sb.Remove(1, sb.Length - 1);
but when it had 9 carriage returns in it like this:
"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"
I got the error:
System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length at System.Text.StringBuilder.Remove(Int32 startIndex,
Int32 length)
You would think there would be a simple Clear() method.
Thanks.
object? I was using this code:
sb.Remove(1, sb.Length - 1);
but when it had 9 carriage returns in it like this:
"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"
I got the error:
System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length at System.Text.StringBuilder.Remove(Int32 startIndex,
Int32 length)
You would think there would be a simple Clear() method.
Thanks.