Last post Jun 20, 2011 04:14 AM by rsoni1980
Dec 13, 2007 01:36 AM|Ez416|LINK
i have this code something like....
<Select * from............................>
<select * from ... where >
I want sb to be cleared after an email was sent. the problem is all the information from the start are included.
Dec 13, 2007 04:38 AM|naturehermit|LINK
Sb= new Stringbuilder
or sb.Remove(0, sb.length)
there is one more way by setting sb.length = 0 should be the fastest. it has been suggested that it is 10,000,000 times appending a 250 character string and setting length=0 afterwards, took only ~4 seconds.
Choice is yours
Jun 20, 2011 04:14 AM|rsoni1980|LINK
String builder does not have a clear method to clear the contents of stringBuilder, but if we want to add a clear method in StringBuilder, use the following method in your utility class.
public static void Clear(this StringBuilder stringBuilder)
stringBuilder.Length = 0;
stringBuilder.Capacity = 16;
Benefit of this method is if we use same stringbuilder variable with clear the existing contents.
StringBuilder sb =new StringBuilder();
// If you want to clear the content of sb then