String-Concatenation Operators Bitwise Operators

50

2.12.4 String-Concatenation Operators

The ampersand and + plus characters signify string concatenation. String concatenation is defined for operands of type String only. The result is a string that consists of the characters from the first operand followed by the characters from the second operand.

2.12.5 Bitwise Operators

It is sometimes necessary to manipulate the individual bits that make up a value of one of the integer types Byte, Short, Integer, and Long. This is the purpose of the bitwise operators. They are defined for the four integer types and for enumerated types. When the bitwise operators are applied to enumerated types, the operation is done on the underlying type, but the result is of the enumerated type. The bitwise operators work by applying the given Boolean operation to each of the corresponding bits in the two operands. For example, consider this expression: 37 And 148 To calculate the value of this expression, consider the binary representation of each operand. Its helpful to write one above the other so that the bit columns line up: 00100101 37 10010100 148 Next, apply the Boolean And operation to the bits in each column: 00100101 37 And 10010100 148 -------- 00000100 4 37 And 148 , therefore, equals 4 . The bitwise operators are: And Performs a Boolean And operation on the bits. The result bit is 1 if and only if both of the source bits are 1 . AndAlso The result is True if and only if both the operands are True ; otherwise, the result is False . AndAlso performs logical short-circuiting: if the first operand of the expression is False , the second operand is not evaluated. Or Performs a Boolean Or operation on the bits. The result bit is 1 if either or both of the source bits are 1 . OrElse 51 The result is True if either or both the operands is True ; otherwise, the result is False . OrElse performs logical short-circuiting: if the first operand of the expression is True , the second operand is not evaluated. Xor Performs a Boolean exclusive or operation on the bits. The result bit is 1 if either of the source bits is 1 , but not both. Not Performs a Boolean Not operation on the bits in the operand. This is a unary operator. The result is 1 if the source bit is and if the source bit is 1 .

2.12.6 Logical Operators