.net - string 是不可变的,而 stringbuilder 是可变的

谁能举例说明


相关讨论: Most efficient way to concatenate strings?

最佳答案

string s = "a";

s += "b"; // this will create a new string object

StringBuilder sb = new StringBuild();
sb.Append("a");
sb.Append("b"); // appends to existing StringBuilder

https://stackoverflow.com/questions/665499/

相关文章:

php - 如何从页面(php)获取所有网址

.net - .NET 是框架还是库?

php - 如何在php中检查文件是否为视频类型?

angular - mat-sort-header/mat-sort 不适用于特定列

regex - 正则表达式 ^(\d{1,2})$ 是什么意思?

perl - 将哈希分配给哈希

xml - 任何想法为什么图案化的 SVG 文件在浏览器中显示为空白?

r - 如何在 R 中计算一个月的第三个星期五

php - 如何将键添加到php数组?

performance - 给 Perl 的 print 一个列表或一个连接的字符串是否更快?