问题详情

StringStringBuilder的异同


时间:2021-12-23 13:26 关键词: C#程序设计 计算机科学技术

答案解析

<p> string的确是不能修改的:<br> stringstr=&quot;a&quot;;<br> str=&quot;b&quot;//str是被赋值了&quot;b&quot;没错,但是str里面原来的string值&quot;a&quot;并没有被修改。<br> stringstr=&quot;a&quot;;<br> stringstr1=str;<br> str+=&quot;b&quot;;//此时str=&quot;ab&quot;,str1=&quot;a&quot;;<br> StringBuilderstr=newStringBuilder(&quot;a&quot;);<br> StringBuilderstr1=str;<br> str.Append(&quot;b&quot;);<br> str.ToString()和str1.ToString()都是&quot;ab&quot;。</p>