Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Culture and UICulture?

People also ask

What is difference between CurrentCulture and CurrentUICulture?

CurrentCulture is the . NET representation of the default user locale of the system. This controls default number and date formatting and the like. CurrentUICulture refers to the default user interface language, a setting introduced in Windows 2000.

What is Application culture?

App Culture is the mobile application designed to respond to the need for safety during visits to museums and archaeological areas through the dissemination of correct behavior and the guarantee of social distancing along the way.

How do you change the current UI culture?

Explicitly Setting the Current UI Culture NET Framework 4.6, you can change the current UI culture by assigning a CultureInfo object that represents the new culture to the CultureInfo. CurrentUICulture property.

What is the use of CurrentCulture property?

CurrentCulture property to retrieve and set the current culture. The CultureInfo object that this property returns is read-only. That means you can't mutate the existing object, for example, by changing the DateTimeFormat .


Culture affects how culture-dependent data (dates, currencies, numbers and so on) is presented. Here are a few examples:

var date = new DateTime(2000, 1, 2);
var number = 12345.6789;

Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
Console.WriteLine(date); // 02.01.2000 00:00:00
Console.WriteLine(number.ToString("C")); // 12.345,68 €

Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA");
Console.WriteLine(date); // 2000-01-02 00:00:00
Console.WriteLine(number.ToString("C")); // 12 345,68 $

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Console.WriteLine(date); // 1/2/2000 12:00:00 AM
Console.WriteLine(number.ToString("C")); // $12,345.68

Culture also affects parsing of user input in the same way:

const string numberString = "12.345,68";
decimal money;

Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
money = decimal.Parse(numberString); // OK!

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
money = decimal.Parse(numberString); // FormatException is thrown, TryParse would return false

Beware of cases where the parsing succeeds but the result is not what you would expect it to be.

const string numberString = "12.345";
decimal money;

Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
money = decimal.Parse(numberString); // 12345

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
money = decimal.Parse(numberString); // 12.345, where the . is a decimal point

UICulture affects which resource file (Resources.lang.resx) is going to be loaded to by your application.

So to load German resources (presumably localized text) you would set UICulture to the German culture and to display German formatting (without any impact on which resources are loaded) you would set Culture.


Culture and UICulture

Values are pairs of two-letter strings, the first is for defining language and the second for defining the region. Example:

en-GB here en represents English and GB represents Great Briton

en-US here en represents English and US represents United States

Use Culture for Culture dependent functions like date, time. and UICulture is for correct resource file loading.