The &operator

Posted Mon, Jun 25 2007 13:52 by bill

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

Filed under: , ,

Comments

# re: The &operator

Monday, June 25, 2007 12:41 PM by Roger Jennings

Bill,

You got me on this one. Mea culpa.

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

Cheers,

--rj