Concat strings by & and + in VB.Net

后端 未结 8 946
萌比男神i
萌比男神i 2020-12-16 10:53

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?

8条回答
  •  醉话见心
    2020-12-16 11:22

    & 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.

提交回复
热议问题