Why does the first if statement evaluate to true? I know if I use \"is\" instead of \"=\" then it won\'t evaluate to true. If I replace String.Empty with \"Foo\" it doesn\
It's a special case of VB's =
and <>
operators.
The Language Specification states in Section 11.14:
When doing a string comparison, a null reference is equivalent to the string literal "".
If you are interested in further details, I have written an in-depth comparison of vbNullString
, String.Empty
, ""
and Nothing
in VB.NET here: