感觉应该有个sb.Clear();或者sb.Empty();之类,但是没有,只能用sb.Remove(0,sb.Length);
代码
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("hello");
sb.Append("world");
Response.Write("Length:" + sb.Length);
sb.Remove(0, sb.Length);//清空StringBuilder的方法
Response.Write("|" + sb.ToString() + "|");
sb.Append("hello");
sb.Append("world");
Response.Write("Length:" + sb.Length);
sb.Remove(0, sb.Length);//清空StringBuilder的方法
Response.Write("|" + sb.ToString() + "|");