I was trying to compare two chars ignoring the case and came up with the following disturbing code trying to play with the now famous turkish i :
char lowerCase = 'ı'; // U+0131
char upperCase = 'I'; // regular upper i
// Displays True comparing the chars
Trace.WriteLine(char.ToUpper(lowerCase, CultureInfo.CurrentCulture) == char.ToUpper(upperCase, CultureInfo.CurrentCulture));
// Displays False comparing the strings
Trace.WriteLine(lowerCase.ToString().Equals(upperCase.ToString(), StringComparison.CurrentCultureIgnoreCase));
The two things are using my culture (french) and seems to do the same thing but the result is not what i expected (either both True or both False).
When using the turkish culture with :
Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");
The result changes and both return True.
Do i miss something about Culture or char/string comparison ?
Edit
Reading this question, I now understand the two are different. It has nothing to do with comparing chars or string but with handling myself the case or not. What I don't understand is why they are different. Isn't the string.Equals with a CurrentCultureIgnoreCase supposed to compare upper case versions of the strings as i do ? What is behind the scene that i can't see ?