Is there any difference between & and + operators while concatenating string? if yes, then what is difference? And if No, then why below code generating exception?
Example:
Dim s, s1, t As String
Dim i As Integer
s1 = "Hello"
i = 1
s = s1 & i
t = s1 + i //Exception here
If s = t Then
MessageBox.Show("Equal...")
End If
+was even a concatenation operator in VB. That's one of the things I hate about JavaScript is that+is for concat and addition.&concatenation operator is one of the things I love about VB. And if you're using+when there's an alternative available, that's not the language's fault, it's your fault as a programmer for not knowing the language.+doubles as a concatenation operator in some languages, and I used JavaScript as an example, as that's where I deal with it the most. I completely agree, I love the fact that&is a separate concat operator in VB, and that's all I knew even existed as a concat operator in VB until now. VB is my primary language for desktop applications.