vb Nullable syntax accepts C# shorthand?

xinull

New member
Joined
Jun 14, 2010
Messages
1
Programming Experience
10+
Hi everyone,

By accident i put in some C# shorthand synthax in a vb.net project, and to my suprise, it compiled and runs fine! Does anyone know if this was a framework update? I can't find any documentation that points this out

The following Vb.net code works fine for me

Dim someDate As DateTime? = Nothing

If someDate.HasValue Then
Console.WriteLine(someDate.Value)
End If
 
Things like DateTime?, Integer?, Short?, Decimal? etc have been allowed in vb since VS2005. They might have been allowed since VS2002 (since day 1 of .Net) I just don't remember that far back.
 
Nullable Value Types The .Net 3.5 (VB 2008) version of this document is the first that use the ? notation, I don't have VB 2005 installed anymore so I can't verify if that was possible also then, but JB seems to know. Generics, which allow the Nullable(Of T) syntax, was introduced with .Net 2.0. A similar feature in VB, type characters, is something that pre-dates .Net.
 
Back
Top