I ran across this and was wondering if someone could explain why this works in VB.NET when I would expect it should fail, just like it does in C#
//The C# Version
struct Person {
public string name;
}
...
Person someone = null; //Nope! Can't do that!!
Person? someoneElse = null; //No problem, just like expected
But then in VB.NET...
Structure Person
Public name As String
End Structure
...
Dim someone As Person = Nothing 'Wha? this is okay?
Is Nothing not the same as null (Nothing != null - LOL?), or is this just different ways of handling the same situation between the two languages?
Why or what is handled differently between the two that makes this okay in one, but not the other?
[Update]
Given some of the comments, I messed with this a bit more... it seems as if you actually have to use Nullable if you want to allow something to be null in VB.NET... so for example...
'This is false - It is still a person'
Dim someone As Person = Nothing
Dim isSomeoneNull As Boolean = someone.Equals(Nothing) 'false'
'This is true - the result is actually nullable now'
Dim someoneElse As Nullable(Of Person) = Nothing
Dim isSomeoneElseNull As Boolean = someoneElse.Equals(Nothing) 'true'
Too weird...