I found that one at the Visual Basic Team Blog. Over here she puts together a list of some of the new features in Visual Basic 2008:
I like these ![]()
2) If Operator
Ever notice that the IIF function returns something of type Object? This means that you don’t get Intellisense or type-checking by default on that result. For those of you that insist on type-safe, early-bound code, you have to cast the result. The code then looks something like this:
Dim intC As Integer = CInt(IIf(intA = intB, intA, intB - 1))
With the If operator, you can now write that line as:
Dim intD As Integer = If(intA = intB, intA, intB)
And with type inference it gets even easier on the eyes:
![]()
4) Nullable
Nullable is the feature you’ll notice but rarely have to think about. It’s basically the .NET representation for a Nullable value type (Integer, Date, etc.) Using the designer for LINQ to SQL, the Object-Relational Mapping layer introduced in Visual Studio 2008, nullable columns in your database are mapped to this type. The result is that you can write the following expression in VB and the right thing happens – null valued rows propagate null. In the example below, the Independence property on the Country type is a nullable date, denoted as Date?
Dim virginIslands As New Country With {.Independence = Nothing} Dim palau As New Country With {.Independence = #10/1/1994#} Dim vILength = #8/24/2005# - virginIslands.Independence ' Nothing Dim pLength = #8/24/2005# - palau.Independence ' 3980.00:00:00
9) Type inference for loop variables
Check out the following code:
![]()
And this code:
![]()
Without having to specify the type of the control variable, it’s inferred from right-hand-side expression or the collection we’re iterating over.