Comparing two strings is easy and simple, right? Wrong. Check out this article which deals with string comparison in .net 2.0. As an exercise guess the output of this piece of code:
Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); Console.WriteLine("Culture = {0}", Thread.CurrentThread.CurrentCulture.DisplayName); Console.WriteLine("(file == FILE) = {0}", (String.Compare("file", "FILE", true) == 0));
True or false, that’s the question.
If it’s Turkish, it’s false. 🙂
Indeed.