VBScript 的 + 和 & 有什么区别?操作员? [英] What is the difference between VBScript's + and & operator?
问题描述
在每个讨论 VBScript 的站点上,&
"运算符都被列为字符串连接运算符.但是,在我最近继承的一些代码中,我看到使用了 '+
' 运算符,并且我没有看到任何由此产生的错误.这是可接受的替代方案吗?
On every site that talks about VBScript, the '&
' operator is listed as the string concatenation operator. However, in some code that I have recently inherited, I see the '+
' operator being used and I am not seeing any errors as a result of this. Is this an accepted alternative?
推荐答案
+ 运算符被重载,而 &运营商不是.&运算符只进行字符串连接.在某些圈子中 &运算符被用作最佳实践,因为它是明确的,因此不会因重载而产生任何意外影响.
The + operator is overloaded, whereas the & operator is not. The & operator only does string concatenation. In some circles the & operator is used as a best practice because it is unambiguous, and therefore cannot have any unintended effects as a result of the overloading.
这篇关于VBScript 的 + 和 & 有什么区别?操作员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!