Visual Basic .NET Handling of Reserved Words


Visual Basic .NET Unleashed
By Paul Kimmel
Table of Contents
Chapter 2.  Out with the Old, In with the New

Visual Basic .NET allows you to use reserved words in code. If you accidentally use a reserved word, such as Enum, as a variable, the IDE will place square brackets around the word. You can then use the reserved word in a non-reserved way as long as every occurrence has the brackets around the reserved word.

Using reserved words in this way probably isn't a good idea because it may lead to confusing, unsightly code. It's also a safe bet that this quirk won't survive for long.

Unfortunately, there are times when you may not be able to avoid using keywords, especially when they define a type. The System.Reflection namespace defines the type Assembly. Assembly is both a type and a keyword. When you declare Assembly variables , the code editor will add the brackets around the Assembly type declaration but may not always add the brackets, especially when a reserved word is used as a variable name .


Visual BasicR. NET Unleashed
Visual BasicR. NET Unleashed
Year: 2001
Pages: 222 © 2008-2017.
If you may any questions please contact us: