Created
August 31, 2011 05:08
-
-
Save justinvp/1182858 to your computer and use it in GitHub Desktop.
Problem with StringComparison.CurrentCulture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
using System.Threading; | |
class Program | |
{ | |
static void Main() | |
{ | |
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); | |
Console.WriteLine("id".Equals("ID", StringComparison.CurrentCultureIgnoreCase)); // True | |
Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); | |
Console.WriteLine("id".Equals("ID", StringComparison.CurrentCultureIgnoreCase)); // False <- bug | |
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); | |
Console.WriteLine("id".Equals("ID", StringComparison.OrdinalIgnoreCase)); // True | |
Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); | |
Console.WriteLine("id".Equals("ID", StringComparison.OrdinalIgnoreCase)); // True | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment