The &operator

I just read again today the claim that you should use + for string concatenation in VB.  You should NOT.  Just because you can doesn’t mean you should.  VB has the Concatenation operator & as distinct from the + operator. Yes for the most part adding two strings is the same as concatenating them, but adding two variables is very different from concatenating them… that’s why in a dynamic language it is important to have two different operators.

The correct one to use is & for concatenation, and use + for addition.  So for strings use &.

See my previous blog entries on this for more details….

http://msmvps.com/blogs/bill/archive/2006/04/23/92280.aspx



1 Comment so far

  1.   Roger Jennings on June 25th, 2007          

    Bill,

    You got me on this one. Mea culpa.

    See the update at http://oakleafblog.blogspot.com/2007/06/visual-basic-team-starts-linq-cookbook.html.

    Cheers,

    –rj