In VB.NET, there are two operators that I use in the concatenation of strings , the
&
and the
In VB.NET, there are two operators that I use in the concatenation of strings , the
&
and the
Essentially there is no difference. &
is the VB way of doing concatenation (it's the legacy language style when it was just VB). +
is the VB.Net way of doing it (it was added to the syntax to get closer to C #, your sibling). So it's like, it's only recommended to choose one and always use that. The two live together as much as possible.
Who is used to C #, and it is common for people to have to deal with C #, even if it is in code samples for .NET that has a lot more to C # than VB.Net, +
seems more natural. Some people do not like it because it can be confused with the arithmetic operator. What even makes some sense in VB that is dynamically typed.
In fact there may be some ambiguity for the compiler when using +
, so it is usually recommended to &
. See the confusion in dotNetFiddle . So ideally you're always using Option Strict On
to be happy
In my conception &
is wrong even using the strict type conversion option since the 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. See a little better at dotNetFiddle (Strict On) .
Of course, this makes little difference if you consider that the language was not designed for robust systems. VB is one of those languages that started to do scripts . When the era of robust languages for complex systems arose she was adapting to meet this new demand. But some addictions 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 the person does not have a base of understanding of the concatenation of string both are weird. If she knows how it works it does not really matter which operator is used. &
is used only in VB.Net. +
is more or less standard in most languages.
Normal use has no performance difference. There can 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 the same output.
As far as I know, they do not have specific names. The generic is concatenation operator. The symbols have names, but no context with this question.