StringBuilder功能演练
Class1 cl = new Class1();
StringBuilder cl = new StringBuilder("hello C#");
String zf = cl.ToString();
cl.Append("为尾部增加内容");
cl.AppendLine("添加内容 自动换行");
cl.Insert(5, "添加中部内容");
cl.Remove(1, 2);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
StringBuilder cl = new StringBuilder("hello C#");
String zf = cl.ToString();
cl.Append("为尾部增加内容");
cl.AppendLine("添加内容 自动换行");
cl.Insert(5, "添加中部内容");
cl.Remove(1, 2);
Console.WriteLine(cl);
Console.ReadKey();
}
}
}
- 详情效果

总结
空对象 | StringBuilder |
---|
尾部添加内容 | Append |
添加内容并自动换行 | AppendLine |
添加中部插入 | Insert |
删除数据 | Remove |