If you are startled by seeing String.Equals returning false for exactly similar looking strings, this is what you need to do:
- Check if both strings have equal lengths, if not return
- Check Trimmed versions of both strings, there maybe extra white-spaces that get unnoticed.
- Finally if both lengths are equal and trimmed versions look exactly the same, the issue could be the encoding of the spaces in the 2 strings as they maybe be coming from different sources. In this case, use the following code to correct the encoding:
Using regex, I have just replaced the unicode equivalent of space with a space.