Skip to content

Instantly share code, notes, and snippets.

@justinvp
Created August 31, 2011 05:08
Show Gist options
  • Save justinvp/1182858 to your computer and use it in GitHub Desktop.
Save justinvp/1182858 to your computer and use it in GitHub Desktop.
Problem with StringComparison.CurrentCulture
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