tabs ↹ over ␣ ␣ ␣ spaces

by Jiří {x2} Činčura

CultureInfo equality

13 Jan 2012 .NET, Best practice or not?, C#

I have a small morale from today. I was writing some code that was handling searching for items base also on CultureInfo. Because it’s a pretty straightforward object, in core of .NET Framework (it’s in mscorlib) I was expecting to handle equality using == based on culture itself not the object. And of course, I was wrong. 😃

The code below should explain it clearly (CurrentUICulture might be different based on your system).

// false
System.Threading.Thread.CurrentThread.CurrentUICulture == System.Globalization.CultureInfo.GetCultureInfo("en-US");
// true

Yep. Learning something every day.