What's New for Visual Basic
Updated: July 20, 2015
This page lists key feature names for each version of Visual Basic with descriptions of the new and enhanced features in the lastest version of the language.
Visual Basic / Visual Studio .NET 2002
Visual Basic / Visual Studio .NET 2003
Bit shift operators, loop variable declaration
Visual Basic / Visual Studio .NET 2005
My type and helper types (access to app, computer, files system, network
Visual Basic / Visual Studio .NET 2008
Language Integrated Query (LINQ), XML literals, local type inference, object initializers, anonymous types, extension methods, local
var type inference, lambda expressions,
if operator, partial methods, nullable value types
Visual Basic, Visual Studio .NET 2010
Auto-implemented properties, collection initializers, implicit line continuation, dynamic, generic co/contra variance, global namespace access
Visual Basic / Visual Studio .NET 2012
await, iterators, caller info attributes
Visual Basic / Visual Studio .NET 2013
technology previews of .NET Compiler Platform (“Roslyn”)
Visual Basic / Visual Studio .NET 2015
Current version, see below
You can get the unqualified string name of a type or member for use in an error message without hard coding a string. This allows your code to remain correct when refactoring. This feature is also useful for hooking up model-view-controller MVC links and firing property changed events.
You can use string interpolation expressions to construct strings. An interpolated string expression looks like a template string that contains expressions. C# creates a string by replacing the expressions with the ToString represenations of the expressions’ results. An interpolated string is easier to understand with respect to arguments than Composite Formatting.
Null-conditional Member Access and Indexing
You can test for null in a very light syntactic way before performing a member access (
?.) or index (
?) operation. These operators help you write less code to handle null checks, especially for descending into data structures. If the left operand or object reference is null, the operations returns null.
Multi-line String Literals
String literals can contain newline sequences. You no longer need the old work around of using
<xml><![CDATA[...text with newlines...]]></xml>.Value
You can put comments after implicit line continuations, inside initializer expressions, and amongst LINQ expression terms.
Smarter Fully-qualified Name Resolution
Given code such as
Threading.Thread.Sleep(1000), Visual Basic used to look up the namespace "Threading", discover it was ambiguous between System.Threading and System.Windows.Threading, and then report an error. Visual Basic now considers both possible namespaces together. If you show the completion list, the Visual Studio editor lists members from both types in the completion list.
Year-first Date Literals
You can have date literals in yyyy-mm-dd format,
#2015-03-17 16:10 PM#.
Readonly Interface Properties
You can implement readonly interface properties using a readwrite property. The interface guarantees minimum functionality, and it does not stop an implementing class from allowing the property to be set.
TypeOf <expr> IsNot <type>
For more readability of your code, you can now use
#Disable Warning <ID> and #Enable Warning <ID>
You can disable and enable specific warnings for regions within a source file.
XML Doc-comment Improvements
When writing doc comments, you get smart editor and build support for validating parameter names, proper handling of
crefs (generics, operators, etc.), colorizing, and refactoring.
Partial Module and Interface Definitions
In addition to classes and structs, you can declare partial modules and interfaces.
#Region Directives inside Method Bodies
You can put #Region…#End Region delimiters anywhere in a file, inside functions, and even spanning across function bodies.
Overrides Definitions are Implicitly Overloads
If you add the
Overrides modifier to a definition, the compiler implicitly adds
Overloads so that you can type less code in common cases.
CObj Allowed in Attributes Arguments
The compiler used to give an error that CObj(…) was not a constant when used in attribute constructions.
Declaring and Consuming Ambiguous Methods from Different Interfaces
Previously the following code yielded errors that prevented you from declaring
IMock or from calling
GetDetails (if these had been declared in C#):
Interface ICustomer Sub GetDetails(x As Integer) End Interface Interface ITime Sub GetDetails(x As String) End Interface Interface IMock : Inherits ICustomer, ITime Overloads Sub GetDetails(x As Char) End Interface Interface IMock2 : Inherits ICustomer, ITime End Interface
Now the compiler will use normal overload resolution rules to choose the most appropriate
GetDetails to call, and you can declare interface relationships in Visual Basic like those shown in the sample.