Nothing = String.Empty (Why are these equal?)

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:

  • https://stackoverflow.com/a/34069187/87698

Nothing in VB.net is the default value for a type. The language spec says in section 2.4.7:

Nothing is a special literal; it does not have a type and is convertible to all types in the type system, including type parameters. When converted to a particular type, it is the equivalent of the default value of that type.

So, when you test against String.Empty, Nothing is converted to a string, which has a length 0. The Is operator should be used for testing against Nothing, and String.Empty.Equals(Nothing) will also return false.