H
Herfried K. Wagner [MVP]
Charles Law said:Because
MyDateTimeVar.Equals(Nothing)
returns True.
Not just unfortunate, I would say, but simply wrong.
Why? 'Nothing' in VB simply means "the type's default value", which is a
'Nothing' reference for value types and "all zeroes" for value types. Note
that you'd have to write 'default(<Type>)' in C# to archieve the same result
as setting a variable of a value type to 'Nothing' in VB. BTW, the behavior
is specified.
In addition, you could even write 'If MyDateTimeVar = Nothing Then' in VB to
compare a 'Date' to its default value.