My application is failing on a string comparison. I have put in a breakpoint and then used the intermediate window of Visual Studio and done the following experiment
subject
"<#MethodResourceObjectives​>"
subject.Contains("<#Method")
true
subject.Contains("<#MethodResource")
true
subject.Contains("<#MethodResourceObjectives")
true
subject.Contains("<#MethodResourceObjectives>")
false
This would seem to be impossible, has anyone got a clue what could be happening?
It sounds like there may well be an unprintable character between the "s" and the ">".
I usually use something like this to show the true contents of a string:
for (int i = 0; i < text.Length; i++)
{
Console.WriteLine("{0:x4}", (int) text[i]);
}
That's not as convenient from an immediate window, of course :(
In fact, just copying and pasting your text into my Unicode Explorer (at the bottom of the page), it looks like this is indeed the problem - you've got a U+200B (zero width space) before the >
. You need to work out where that's coming from.
See more on this question at Stackoverflow