Nothing = String.Empty (Why are these equal?)
Posted
by Ek0nomik
on Stack Overflow
See other posts from Stack Overflow
or by Ek0nomik
Published on 2010-04-13T21:01:30Z
Indexed on
2010/04/13
21:03 UTC
Read the original article
Hit count: 309
I find it very puzzling that null equals String.Empty in VB.NET. There must be an explanation for it that I'm not understanding. Somehow, when the equality of String.Empty (which has an object type of string) is tested against Nothing (which has no type) the test returns true.
It just seems like a turn around in logic to me. In SQL if I were to compare an empty char or varchar against a null value, the test wouldn't return true. A null value is not the same as an empty string in this case. Yet in VB.NET they are equal.
I'd love it if someone could provide a good explanation around this.
© Stack Overflow or respective owner