I can’t find a definitive answer. Since C# 2.0 you’ve been able to declare
int? i = 125;
as shorthand for
Nullable<int> i = Nullable<int>(123);
I recall reading somewhere that VB.NET did not allow this shortcut. But low and behold, I tried it in VS 2008 today and it works.
Does anyone know whether it’s been this way since .NET 2.0 or was this added later?
System.Nullable was introduced in .Net 2.0 and is available to VB as a generic type. You just cannot use the nullable syntax. So in VS 2005 you can do:
I don’t know if null equivalence and boxing works for nullables in VB 2005, but I would suspect that the answer is yes since the .Net team made a change to the 2.0 CLR to accomplish boxing with nullables. I would imagine VB leverages this.
In 2008, you can obviously just do: