13.2. VB.NET

Very few new language features are available only in VB.NET, the most significant being the My namespace, which is covered in detail in the next chapter. This said, there are some small additions to the language that are worth knowing about.

13.2.1. IsNot

The IsNot operator is the counterpart to the Is operator that is used for reference equality comparisons. Whereas the Is operator will evaluate to True if the references are equal, the IsNot operator will evaluate to True if the references are not equal. Although a minor improvement, this keyword can save a considerable amount of typing, eliminating the need to go back to the beginning of a conditional statement and insert the Not operator:

Dim aPerson As New Person
Dim bPerson As New Person
If Not aPerson Is bPerson Then
    Console.WriteLine("This is the old way of doing this kind of check")
End If
If aPerson IsNot bPerson Then
    Console.WriteLine("This is the old way of doing this kind of check")
End If

Not only does the IsNot operator make it more efficient to write the code; it also makes it easier to read. Instead of the "Yoda-speak" expression If Not aPerson Is bPerson Then, you have the much more readable expression If aPerson IsNot bPerson Then.

13.2.2. Global

The VB.NET Global keyword is very similar to the C# identifier with the same name. Both are used to escape to the outermost namespace, and both are used to remove any ambiguity when resolving namespace and type names. In the following example the System ...

Get Professional Visual Studio® 2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.