If you call IndexOf
with the soft hyphen character as parameter, it will work as expected:
"aaa".IndexOf(Convert.ToChar(173)) // return -1
"aaa\u00AD".IndexOf(Convert.ToChar(173)) // return 3
However, if you call the exact same code using the soft hyphen as a string, the returned value will be 0 even if there's no soft hyphen in the string.
"aaa".IndexOf(Convert.ToChar(173).ToString()) // return 0
"aaa\u00AD".IndexOf(Convert.ToChar(173).ToString()) // return 0
Why does the IndexOf
fails when you use a string?