Common methods of StringBuilder objects,
Obtain an empty StringBuilder object
StringBuilder nb = new StringBuilder();
Obtain a StringBuilder object with initial value
StringBuilder nb = new StringBuilder("hello C#");
Convert string
String a = nb.ToString();
Output after printing
//第一次打印
Console.WriteLine(a);
Add content at the end
尾部添加内容 对象.Append(字符串)
nb.Append("666");
Second print
//第二次打印 输出要写对象
Console.WriteLine(nb);
Add a new line
//添加一行自动换行 sb对象.AppendLine(内容)
sb.AppendLine("abc");
Third print
//第三次打印
Console.WriteLine(sb);
Middle insertion
//中部插入 sb对象.Insert(下标,内容)
sb.Insert(5,"中部插入");
Fourth print
//第四次打印
Console.WriteLine(sb);
delete data
//删除数据 sb对象.Remove(起始索引,删除长度)
sb.Remove(5,4);
Fifth print
//第五次打印
Console.WriteLine(sb);