InternetUnicodeHTMLCSSScalable Vector Graphics (SVG)Extensible Markup Language (xml) ASP.Net TOCASP.NetMiscellaneous Feature ASP.NET Scripting Visual Basic .NET TOCVB .NET Language ReferencenaVB.Net Elements OperatorArithmetic OperatorCompare Operator Draft for Information Only
Content
VB.NET Concatenation Operators
VB.NET Concatenation OperatorsThe supporting VB.NET Concatenation Operators are &, +. & OperatorGenerates a string concatenation of two expressions. Syntaxresult = expression1 & expression2 Partsresult: 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. RemarksIf 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 "". 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. See also
+ OperatorAddition operator. Adds two numbers or returns the positive value of a numeric expression. Can also be used to concatenate two string expressions. Syntaxexpression1 + expression2 - or - + expression1 Partsexpression1: Required. Any numeric or string expression. expression2: Required unless the + operator is calculating a negative value. Any numeric or string expression. ResultIf expression1 and expression2 are both numeric, the result is their arithmetic sum. If expression2 is absent, the + operator is the unary identity operator for the unchanged value of an expression. In this sense, the operation consists of retaining the sign of expression1, so the result is negative if expression1 is negative. If expression1 and expression2 are both strings, the result is the concatenation of their values. If expression1 and expression2 are of mixed types, the action taken depends on their types, their contents, and the setting of the Option Strict Statement. For more information, see the tables in "Remarks." Supported TypesAll numeric types, including the unsigned and floating-point types and Decimal, and String. RemarksIn general, + performs arithmetic addition when possible, and concatenates only when both expressions are strings. If neither expression is an Object, Visual Basic takes the following actions.
If one expression is an Object expression, Visual Basic takes the following actions.
If both expressions are Object expressions, Visual Basic takes the following actions (Option Strict Off only).
If either Object expression evaluates to Nothing or DBNull, the + operator treats it as a String with a value of "". Note When you use the + operator, you might not be able to determine whether addition or string concatenation will occur. Use the & operator for concatenation to eliminate ambiguity and to provide self-documenting code. OverloadingThe + 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. See also
Source/Reference
©sideway ID: 200800002 Last Updated: 8/2/2020 Revision: 0 Ref: ![]() References
![]() Latest Updated Links
![]() ![]() ![]() ![]() ![]() |
![]() Home 5 Business Management HBR 3 Information Recreation Hobbies 8 Culture Chinese 1097 English 339 Travel 18 Reference 79 Computer Hardware 254 Software Application 213 Digitization 37 Latex 52 Manim 205 KB 1 Numeric 19 Programming Web 289 Unicode 504 HTML 66 CSS 65 SVG 46 ASP.NET 270 OS 431 DeskTop 7 Python 72 Knowledge Mathematics Formulas 8 Set 1 Logic 1 Algebra 84 Number Theory 206 Trigonometry 31 Geometry 34 Calculus 67 Engineering Tables 8 Mechanical Rigid Bodies Statics 92 Dynamics 37 Fluid 5 Control Acoustics 19 Natural Sciences Matter 1 Electric 27 Biology 1 |
Copyright © 2000-2025 Sideway . All rights reserved Disclaimers last modified on 06 September 2019