|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
What's New in the Visual Basic Language
Visual Basic 2005 introduces new language features, including loop continuation, guaranteed resource disposal, mixed access properties, unsigned and nullable data types, operator overloading, partial and generic types, custom events, and(CLS) compliance checking.
This page lists features that are new to the Visual Basic language with Visual Basic 2005. For a discussion of features and functionality that have changed from earlier versions, see.
Visual Basic now supplies a Continue statement, which immediately skips to the next iteration of a Do, For, or While loop. For more information, seeand .
Visual Basic 6.0 Form Access
Visual Basic now allows you to refer to a defined form, such as Form1, by using its class name, instead of explicitly creating an instance of it. For more information, see.
Visual Basic now furnishes an IsNot operator, with which you can avoid using the Not and Is operators in an awkward order. For more information, seeand .
Visual Basic now provides the TryCast type conversion operator that returns Nothing if the attempted conversion fails, unlike CType and DirectCast which both throw anerror. For more information, see .
Visual Basic now offers a Using...End Using block to ensure disposal of a system resource when your code leaves the block for any reason. For more information, seeand .
Explicit Zero Lower Bound on an Array
Visual Basic now permits an array declaration to specify the lower bound (0) of each dimension along with the upper bound. For more information, see.
Properties with Mixed Access Levels
Visual Basic now allows you to declare a property with different access levels on its Get and Set procedures. For more information, see.
Visual Basic now supports unsigned integer data types (UShort, UInteger, and ULong) as well as the signed type SByte. For more information, see, , , , , and .
Visual Basic now supports extensions of value types that can take either their normal values or a null value. A null value is useful for indicating that a variable has no defined value because the information is not currently available. For more information, seeand .
Visual Basic now allows you to define a standard operator (such as +, &, Not, or Mod) on a class or structure you have defined. For more information, see, , and .
Code Separation using Partial Types
Visual Basic now provides a mechanism to allow the integrated development environment (IDE) to separate generated code from your authored code into separate source files. Most of the time, you only have to deal with the code you wrote. For more information, see.
Visual Basic now supports type parameters on generic classes, structures, interfaces, procedures, and delegates. A corresponding type argument specifies at compilation time the data type of one of the elements in the generic type. For more information, see.
Visual Basic now allows you to have greater control over the detailed behavior of events. You can declare custom events by using the Custom keyword as a modifier for the Event statement. In a custom event, you specify exactly what happens when code adds or removes an event handler to or from the event, or when code raises the event. For examples, see, , and . To maintain backward compatibility with existing code, the Custom keyword is not a reserved keyword.
Compiler Checking Options
Visual Basic 2005 introduces new compiler checking options. Theand options provide more control over how warnings are handled. Each one of these compiler options now takes a list of warning IDs as an optional parameter, to specify to which warnings the option applies.
CLS Compliance Checking
Visual Basic now generates a warning for each line of code that contains any specification or operation that the(CLS) does not support.
Uninitialized Variable Checking
Visual Basic now generates a warning for each potentially uninitialized variable. A variable has this status if there is at least one possible execution path that does not assign any value to the variable before using it.
For more information, see.