10 New Things in Visual Basic 2015

10 New things in Visual Basic 201510 New Things in Visual Basic 2015

Visual Basic 2015 provides a number of new features. Here are ten you’ll likely find useful.

Multiline String LiteralsMultiline String Literals

You are now able to split string literals over multiple lines. You are no longer confined to create a variable with a very long string value on one very long line, as you now can split the long string over multiple lines.

String InterpolationString Interpolation

We as VB Developers have been accustomed to using expression placeholders in our strings. With String Interpolation, using an expression inside a string has become much easier. You can directly reference a string variable instead of formatting the string appropriately.

Year-first Date LiteralsYear-first Date Literals

Year-first date literals reduce the ambiguity between writing months first, or days first, inside a date. This simply means that you are allowed to write a date specifying the year first, before specifying the day and month. A small example looks like the following:

Dim dtDate1 = #2015-07-24#  ' yyyy-MM-dd, July 24th 2015

Comments Allowed in More PlacesComments Allowed in More Places

In olden days, it was impossible to add a comment inside a LINQ expression and in-line continuations. With VB 2015, you can add comments basically anywhere, including in-line continuations. Now you can, and it is as easy as the following:

Dim arrEmployees = {"Hannes",    'Me
	}

The ?. OperatorThe ?. Operator

Having to check for NULL values, or values that are Nothing, has always been a pain for me., and I believe for many a fellow VB. Developer. This operator makes it easy to check for null values in objects. Here is an example of its implementation:

Dim EmpObject = Employee.Name

Dim x = Employee.Name?.Surname

Partial Module and Interface DeclarationsPartial Module and Interface Declarations

VB used to only allow Partial on classes and structures. Partial is now allowed in VB 2015 in modules and interfaces, as well. Each source file contains a section of the type or method definition, and all parts are combined when the application is compiled.

Structures Allow Sub New()Structures Allow Sub New()

Visual Basic will allow you to declare a constructor without a parameter for a structure by using New. This means that you simply can provide a value for a member variable inside the New constructor, and you do not need to supply a value via an argument.

'#Region' Directives Inside Method Bodies‘#Region’ Directives Inside Method Bodies

In Visual Studio 2015, you will have the ability to include a Region inside a method. This means that you are no longer constrained to strategically placing #Regions to try to explain what a certain method does — now you can have a Region directive to specify a region in method bodies.

ReadOnly Auto-implemented PropertiesReadOnly Auto-implemented Properties

You now can have ReadOnly auto-implemented properties. Auto-implemented properties allow you to quickly specify a property of a class without having to write code to Get and Set the property. When you write code for an auto-implemented property, the Visual Basic compiler automatically creates the associated Get and Set procedures.

TypeOf <expr data-lazy-src=

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read