Why am I allowed to assign Nothing to a value-type in VB.NET:
Dim x as Integer = Nothing
But I\'m not allowed to assign
The equivalent C# code looks like this:
int x;
x = default(int);
Note that for reference types, the same still holds:
Dim y As Object
y = Nothing
That VB.Net code would look like this if mapped directly to C#:
object y;
y = default(object);
It's just a nice thing that the default for object (or any other reference type) in .Net is null. So we see that VB.Net's Nothing is not a direct analog to C#'s null, at least when used with value types.