In our previous post, “Dynamically Changing Date Separators at Runtime in C# & .NET”, and in others, like “Dynamically Changing Decimal & Thousand Separators At Runtime”, we have been modifying the culture that the current thread is running under.

Like so:


// Clone the current culture, to use as a base
var culture = CultureInfo.InvariantCulture.Clone() as CultureInfo;

// Modify what we want to change - the date separator
culture!.DateTimeFormat.DateSeparator = "+";

// Set the thread's culture to our new culture
Thread.CurrentThread.CurrentCulture = culture;

CurrentCulture here instructs the runtime how to carry out various operations when it comes to the formatting and display of data.

There is a similarly named property, CurrentUICulture, that occasionally trips me up.

This is an entirely different thing, as its purpose is user interface localization. It controls the captions of various user interface elements.

For example, a user might want to use an English interface but display data using French localization.

In which case you can achieve this programmatically as follows:

// Set UI to english
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");

// Set formatting & other aspects to french	
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");

So your buttons and other elements would use English (typically specified using resource files), but the logic around parsing and displaying would use French.

TLDR

CurrentUICulture controls the user interface elements, while CurrentCulture controls formatting and parsing of data.