Some New VB.NET 10 (VS2010) Features

6. April 2010

Read this article in your language IT | EN | DE | ES

 

Autoimplemented Properties (yes C# already had this)

Previous VB.Net 9 (Or VS 2008)

    Private _Name As String
    Public Property Name() As String
        Get
            Return _Name
        End Get
        Set(ByVal value As String)
            _Name = value
        End Set
    End Property

    Private _Addresses As List(Of Car)
    Public Property Addresses() As List(Of Car)
        Get
            Return _Addresses
        End Get
        Set(ByVal value As List(Of Car))
            _Addresses = value
        End Set
    End Property

New VB.Net 10 (Or VS 2010)

Public Property Name() As String

Public Property AddressList() As List(Of Car) = New List(Of Car)

Or (Setting a Default Value)

Public Property Name() As String = "Fred"

Public Property Addresses() As New List(Of Car)

 

Collection Initializers:

 

Public Property Cars As New List(Of Car) from {
                                                New Car With (.Color = “Red", .Make = "Ford"),
                                                New Car With (.Color = “Blue", .Make = "Mazda")
                                              }
 

 

Implicit Line Continuation:

 

No more need for the underscore _ to continue a VB line. You can see from code sample above and from this. 

    Dim Statement As String = "Hello"
        & "World"
        & " All Considered One Line"

 

Watch Video: http://msdn.microsoft.com/en-us/vbasic/ee681550.aspx

VB.NET