Relational Operators Operators and Expressions

48 The addition operator is defined for all numeric operands and operands of an enumerated type. The result is the sum of the operands. For enumerated types, the sum is calculated on the underlying type, but the return type is the enumerated type. See the discussion of enumerated types in the Enumerations section later in this chapter for more information on the types that can underlie an enumerated type. See also Sect ion 2.12.4 later in this section. - subtraction The subtraction operator is defined for all numeric operands and operands of an enumerated type. The result is the value of the first operand minus the second operand. For enumerated types, the subtraction is calculated on the underlying type, but the return type is the enumerated type. See the discussion of enumerated types in Sect ion 2.17 later in this chapter for more information on the types that can underlie an enumerated type.

2.12.3 Relational Operators

The relational operators all perform some comparison between two operands and return a Boolean value indicating whether the operands satisfy the comparison. The relational operators supported by Visual Basic .NET are: = equality The equality operator is defined for all primitive value types and all reference types. For primitive value types and for the String type, the result is True if the values of the operands are equal; False if not. For reference types other than String, the result is True if the references refer to the same object; False if not. If the operands are of type Object and they reference primitive value types, value comparison is performed rather than reference comparison. inequality The inequality operator is defined for all primitive value types and for reference types. For primitive value types and for the String type, the result is True if the values of the operands are not equal; False if equal. For reference types other than String, the result is True if the references refer to different objects; False if they refer to the same object. If the operands are of type Object and they reference primitive value types, value comparison is performed rather than reference comparison. less than The less-than operator is defined for all numeric operands and operands of an enumerated type. The result is True if the first operand is less than the second; False if not. For enumerated types, the comparison is performed on the underlying type. greater than The greater-than operator is defined for all numeric operands and operands that are of an enumerated type. The result is True if the first operand is greater than the second; False if not. For enumerated types, the comparison is performed on the underlying type. = less than or equal to The less-than-or-equal-to operator is defined for all numeric operands and operands of an enumerated type. The result is True if the first operand is less than or equal to the second operand; False if not. 49 = greater than or equal to The greater-than-or-equal-to operator is defined for all numeric operands and operands of an enumerated type. The result is True if the first operand is greater than or equal to the second operand; False if not. TypeOf...Is The TypeOf...Is operator is defined to take a reference as its first parameter and the name of a type as its second parameter. The result is True if the reference refers to an object that is type-compatible with the given type-name; False if the reference is Nothing or if it refers to an object that is not type-compatible with the given type name. Use the TypeOf...Is operator to determine whether a given object: • Is an instance of a given class • Is an instance of a class that is derived from a given class • Exposes a given interface In any of these cases, the TypeOf expression returns True . Is The Is operator is defined for all reference types. The result is True if the references refer to the same object; False if not. Like The Like operator is defined only for operands of type String. The result is True if the first operand matches the pattern given in the second operand; False if not. The rules for matching are: • The ? question mark character matches any single character. • The asterisk character matches zero or more characters. • The number sign character matches any single digit. • A sequence of characters within [] square brackets matches any single character in the sequence. Within such a bracketed list, two characters separated by a - hyphen signify a range of Unicode characters, starting with the first character and ending with the second character. A - character itself can be matched by placing it at the beginning or end of the bracketed sequence. Preceding the sequence of characters with an exclamation mark character matches any single character that does not appear in the sequence. • The ? , , , and [ characters can be matched by placing them within [] in the pattern string. Consequently, they cannot be used in their wildcard sense within [] . • The ] character does not need to be escaped to be explicitly matched. However, it cant be used within [] . 50

2.12.4 String-Concatenation Operators