Skip to content

Latest commit

 

History

History
60 lines (43 loc) · 2.51 KB

concatenation-operator.md

File metadata and controls

60 lines (43 loc) · 2.51 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: & Operator (Visual Basic)
& Operator
07/20/2015
vb.&
And (&) operator
ampersand operator (&)
& operator
concatenation operators [Visual Basic], syntax
strings [Visual Basic], concatenating
fefc3d00-cbf1-475c-8c5e-6fb213b3f85a

& Operator (Visual Basic)

Generates a string concatenation of two expressions.

Syntax

result = expression1 & expression2  

Parts

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.

Remarks

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 xref:System.DBNull.Value?displayProperty=nameWithType, they are treated as a string with a value of "".

Note

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.

Note

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

Example

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

[!code-vbVbVbalrOperators#2]

See also