Wednesday, January 26, 2011

String Concatenation

The & Operator (Visual Basic) is defined only for String operands, and it always widens its operands to String, regardless of the setting of Option Strict. The & operator is recommended for string concatenation because it is defined exclusively for strings and reduces your chances of generating an unintended conversion.
 Dim a As String = "abc"
  
 Dim d As String = "def"
  
 Dim z As String = a & d
  
 Dim w As String = a + d
  

No comments:

Post a Comment