Essentially there is no difference. The &
is the VB way of concatenating (it is the legacy style of the language when it was only VB). The +
is the VB.NET way of doing it (it was added to the syntax to get closer to C#, its co-sister). So it is taste, it is only recommended to choose one and always use like this. The two live well, as far as possible.
Who is used to C#, and it is common to have to deal with C#, even if it is in code examples for . NET that has much more for C# than VB.NET, the +
seems more natural. Some people don’t like it because it can be mistaken for an arithmetic operator. Which even makes some sense in VB which is dynamically typed.
In fact there may be some ambiguity for the compiler when using the +
, so it is customary to recommend the &
. So the ideal is that you’re always using Option Strict On
to be happy.
Behold the confusion in ideone. And in the .NET Fiddle. Also put on the Github for future reference.
In my conception the &
is wrong even using the strict type conversion option since concatenation does the conversion. For me it’s one more reason not to use it. But there is taste for everything. If you find it comfortable, it is ok to use, just understand the differences.
Behold a little better at ideone. And in the .NET Fiddle. Also put on the Github for future reference. (Strict On)
Of course, this makes little difference if you consider that the language was not created for robust systems. VB is one more of those languages that started to do scripts. When the era of robust languages for complex systems arose, it was adapting to meet this new demand. But some vices remained. There is no problem in adopting language. But you have to know that you have to live with these things.
For some people one is more intuitive than another. The fact is that if one does not have a basis of understanding of what concatenation is string both are freaks. If she knows how it works it doesn’t matter much which operator is used. &
is only used in VB.NET. O +
is more or less standard in most languages.
Normal use has no difference in performance. There may be some difference if one of them forces some type conversion. But there you are comparing different things. The comparison is only fair for the same input and same output.
As far as I know they don’t have specific names. Generic is concatenation operator. The symbols have names, but no context with that question.
I believe that the
+
be just a "shortcut" to concatenation or just "another way of doing", since it is an arithmetic operator, and the&
logical operator, for joining, for the little that I found in google has a small impact on performance too, but this relation is more for when using methods likeconcat()
where a number of procedures are to be carried out, the+
is an arithmetic operator for addition even, while the&
logical operator "and", in a sentence where "A and B must be equal and of the same type as C"A && B === C
– Hebert Lima
@Hebertdelima is VB.Net so none of this is worth it.
– Maniero