Skip to Main Content
Professional Visual Studio® 2008
book

Professional Visual Studio® 2008

by Nick Randolph, David Gardner
July 2008
Intermediate to advanced content levelIntermediate to advanced
1026 pages
27h 59m
English
Wrox
Content preview from Professional Visual Studio® 2008

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Professional Visual Studio® 2010

Professional Visual Studio® 2010

Nick Randolph, David Gardner, Michael Minutillo, Chris Anderson

Publisher Resources

ISBN: 9780470229880Purchase book