字符串+ vs& [英] Strings + vs &
本文介绍了字符串+ vs&的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的,
使用+进行字符串连接是否有任何性能差异? vs"&"?
我认为,该编译器为两者生成相同的代码。我是对的吗?
谢谢,
Boni
Dear all,
Is there any perfomance difference in string concatination using "+" vs "&"?
I think, that compiler produces the same code for both. Am I right?
Thank you,
Boni
推荐答案
两者都有相同的速度它是字符串连接。+运算符迟到
绑定并且必须执行类型检查和转换。
问候,
C#, VB.NET,SQL SERVER,UML,DESIGN Patterns面试问题书
http:/ /www.geocities.com/dotnetinterviews/
Both have same speed if it is string concatenation.+ operator is late
bound and must perform type checking and conversions.
Regards ,
C#, VB.NET , SQL SERVER , UML , DESIGN Patterns Interview question book
http://www.geocities.com/dotnetinterviews/
尽管性能可能相同,但我建议使用&因为那里有
的情况下它会编译但行为与你的预期不同
如果你使用+。
(我还没有得到一个方便的例子,但它们存在...)
-
David Anton
www.tangiblesoftwaresolutions.com
即时C#:VB.NET转换为C#转换器
即时VB:C#到VB.NET转换器
即时J#:VB.NET到J#转换器
清除VB:清理过时的VB.NET代码
"希欧波尼"写道:
Even though performance is likely the same, I recommend using & since there
are cases where it will compile but behave differently from what you expect
if you use +.
(I haven''t got an example handy, but they exist...)
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
Clear VB: Cleans up outdated VB.NET code
"Boni" wrote:
亲爱的,
使用+字符串连接是否有任何性能差异? vs"&"?
我认为,该编译器为两者生成相同的代码。我是对的吗?
谢谢你,
Boni
Dear all,
Is there any perfomance difference in string concatination using "+" vs "&"?
I think, that compiler produces the same code for both. Am I right?
Thank you,
Boni
Boni,
有些情况下+开始计数。所以尽量永远使用
&在VB.Net中进行连接
我认为这句话的选项严格是有效的
" 111" + 1它给你112
而
" 111" &安培; 1给你比1111
我希望这有帮助,
Cor
Boni,
There are situations where the + starts counting. So try to use forever the
& for concatination in VB.Net
I thought that it was that with option strict of this sentence is valid
"111" + 1 it gives you "112"
while
"111" & 1 gives you than 1111
I hope this helps,
Cor
这篇关于字符串+ vs&的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文