As several people correctly pointed out, my recent issues with string comparison were due to string interning.
String interning is a (usually) transparent process where by the CLR tries to guarantee that two strings that are value-equivalent are also reference-equivalent. Usually, but not always. The interning rules are quite complex, and I don’t claim to understand them all.
I didn’t write the code that was doing the comparison, so I didn’t have the ability to turn the reference equality comparison into a value comparison (String.Equals()). The only thing I could do was change my code to return String.Empty instead of the compile-time constant “”.
Guess I’ll be more dilligent about returning String.Empty in the future.
