The IndexOf
function called on a string returns -1
, while there definitely is a match.
string sUpperName = "PROGRAMOZÁSI NYELVEK II. ADA EA+GY. (BSC 08 A)";
string sUpperSearchValue = "N";
sUpperName.IndexOf(sUpperSearchValue); // Returns -1
sUpperSearchValue = "NY";
sUpperName.IndexOf(sUpperSearchValue); // Returns 13
sUpperName[13]; // 78 'N'
sUpperSearchValue[0]; // 78 'N'
sUpperName[13] == sUpperSearchValue[0]; // true
Do you have any idea, why it is that it finds "NY"
but not "N"
by itself? If I search for every other letter in the string, it is able to find it, but not the "N"
.
The same issue appears as well with lower case.
If I type " N"
no match either, at " NY"
it does.
Picture of this in console
N
fromNY
tosUpperSearchValue
? (actual ctrl+c, ctrl+v). – SardiusN
is from the latin alphabet and in the other case is from the Hungarian (just guessing here) alphabet. If this is the case, they are different characters and it explains this behaviour – Bergwall