Operators To review, operators are the special symbols, such as +, /, Mod, and AndOr, that allow you to perform arithmetic, bitwise, comparison, concatenation, and logical operations in statements. Each operator takes a prescribed number and type of operands, or data. Several new operators have been added to Visual Basic .NET. Some of these operators are designed to support bitwise logic and others have been defined to provide an abbreviated form of standard arithmetic. Several new assignment operators have been borrowed from C++. Look over Table 2.8 for a review of VB .NET operators. Table 2.8. Visual Basic .NET Operators
Many of these operators you've seen before. We won't rehash those. A few others are new and AddressOf has taken on new importance. Let's take a moment to cover new or changed operators. All operators of the form token = perform two operations. For example, I += 5 is expanded to I = I + 5. These combined operators have been around in C++ for about 12 years or so. AddressOf has taken on new importance in VB .NET. In VB6 you could use the AddressOf operator to pass the address of a procedure to APIs that needed a callback procedure. (A callback is simply a procedure invoked by its address.) In VB .NET you can create your own callbacks and use them in your program. Callbacks are supported directly with the delegate idiom. Read Chapter 9, "Understanding Delegates," for more on this advanced topic. |
Team-Fly |
Top |