为什么没有使用StringBuilder作为参数的StringBuilder.Append重载? [英] Why isn't there an StringBuilder.Append overload with StringBuilder as argument?
本文介绍了为什么没有使用StringBuilder作为参数的StringBuilder.Append重载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么StringBuilder没有StringBuilder.Append()重载?
参数?
有没有我错过的原因?
解决方案
我认为不会因为它没用。现在你可以这样做:
....
stringBuilder2.Append(stringBuilder1.ToString());
.. ..
我找不到为什么需要这样的方法。
" cody" <德******** @ gmx.de> escribióenel mensaje
news:eG ************** @ TK2MSFTNGP10.phx.gbl ...为什么不是''有一个StringBuilder.Append()重载,StringBuilder作为
参数?
我错过了什么原因?
>
>我认为不会因为它没用。现在你可以这样做:
...
stringBuilder2.Append(stringBuilder1.ToString());
...
我找不到为什么需要这样的方法。
你的理由将使所有现有的19个StringBuilder重载
无用。
问题是stringBuilder1.ToString()创建了一个新的字符串我
想要避免。
你如何构建另一个?您也许可以重复使用它,即。使用
单字符串构建器而不是单独创建其中两个然后
组合它们?
-
>
" cody" <德******** @ gmx.de> aécritdansle message de
news:eU ************** @ TK2MSFTNGP14.phx.gbl ...我认为不会因为它没用。现在你可以做到:
...
stringBuilder2.Append(stringBuilder1.ToString());
...
我找不到理由为什么需要这样的方法。
你的理由将使所有现有的19个重载
StringBuilder无用。
问题是stringBuilder1.ToString()创建了一个新的字符串我
我想避免。
Why isn''t there an StringBuilder.Append() overload with a StringBuilder as
argument?
Is there a reason that I missed?
解决方案
I think there isn''t because it would be useless. Now you can do:
....
stringBuilder2.Append(stringBuilder1.ToString());
....
I find no reason why one need such method.
"cody" <de********@gmx.de> escribió en el mensaje
news:eG**************@TK2MSFTNGP10.phx.gbl...Why isn''t there an StringBuilder.Append() overload with a StringBuilder as
argument?
Is there a reason that I missed?
> I think there isn''t because it would be useless. Now you can do:
...
stringBuilder2.Append(stringBuilder1.ToString());
...
I find no reason why one need such method.
Your "reason" would make all of the existing 19 overloads of StringBuilder
"useless".
The problem is that stringBuilder1.ToString() creates a new string which I
want to avoid.
How do you build the other one ? You could perhaps reuse it ie. using a
single string builder rather than creating separately two of them and then
combining them ?
--
"cody" <de********@gmx.de> a écrit dans le message de
news:eU**************@TK2MSFTNGP14.phx.gbl...I think there isn''t because it would be useless. Now you can do:
...
stringBuilder2.Append(stringBuilder1.ToString());
...
I find no reason why one need such method.
Your "reason" would make all of the existing 19 overloads of
StringBuilder "useless".
The problem is that stringBuilder1.ToString() creates a new string which I
want to avoid.
这篇关于为什么没有使用StringBuilder作为参数的StringBuilder.Append重载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文