Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2010
Visual Studio
Visual Basic
 & Operator
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2010/.NET Framework 4

Other versions are also available for the following:
Visual Studio 2010 - Visual Basic
& Operator (Visual Basic)

Generates a string concatenation of two expressions.

result = expression1 & expression2
result

Required. Any String or Object variable.

expression1

Required. Any expression with a data type that widens to String.

expression2

Required. Any expression with a data type that widens to String.

If the data type of expression1 or expression2 is not String but widens to String, it is converted to String. If either of the data types does not widen to String, the compiler generates an error.

The data type of result is String. If one or both expressions evaluate to Nothing or have a value of DBNull..::.Value, they are treated as a string with a value of "".

NoteNote

The & operator can be overloaded, which means that a class or structure can redefine its behavior when an operand has the type of that class or structure. If your code uses this operator on such a class or structure, be sure you understand its redefined behavior. For more information, see Operator Procedures (Visual Basic).

NoteNote

The ampersand (&) character can also be used to identify variables as type Long. For more information, see Type Characters (Visual Basic).

This example uses the & operator to force string concatenation. The result is a string value representing the concatenation of the two string operands.

Visual Basic
Dim sampleStr As String
sampleStr = "Hello" & " World"
' The preceding statement sets sampleStr to "Hello World".
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker