Today at work, Seth, one of my friends, was explaining me the default behavior of VB.NET as a response to my previous post. Apperantly, VB.NET boxes native types automitically for you. So when you set an Integer to Nothing, it’s all good. In other words the following code is all good in VB.NET,
Dim i As Integer = 10
Dim o As Object = i
o = Nothing
i = CInt(o)
As expected, this C# code throws a NullPointerException in the unboxing from object to integer,
int i = 10;
object o = i;
o = null;
i = (int) o;
All I have to say is that VB.NET is messed up.