Ampersand vs plus for concatenating strings in VB.NET
This question already has an answer here:
I've heard good, strong arguments in favor of both operators. Which argument wins the day depends largely on your situation. The one thing I can say is that you should standardize on one or the other. Code that mixes the two is asking for confusion later.
The two arguments I remember right now for favoring &:
Option Strict
and have two numeric strings, it's easy for the compiler to confuse your meaning of of the +
operator with, you know, arithmetic addition And for +:
Micorosoft's preference is for VB progammers to use & for strings, NOT +.
You can also use the + operator to concatenate strings. However, to eliminate ambiguity, you should use the & operator instead.
I prefer using &
for string concatenations in VB.NET
One reason for this is to avoid any confusion eg
MessageBox.Show(1 & 2) ' "12"
MessageBox.Show(1 + 2) ' 3
链接地址: http://www.djcxy.com/p/35134.html
上一篇: c连接NSString