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
& and + are both concatenation operators but when you specify an integer while using +, vb.net tries to cast “Hello” into integer to do an addition. If you change “Hello” with “123”, you will get the result 124.