Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between CurrentCulture and CurrentUICulture properties of CultureInfo in .NET?

In .NET there is the CultureInfo class in the System.Globalization namespace. It has two similar properties both returning values of the CultureInfo type: CurrentCulture and CurrentUICulture.

What is the difference between them?

Which one should I use when and why?

like image 235
splattne Avatar asked Nov 30 '08 16:11

splattne


Video Answer


2 Answers

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. This is primarily regarding the UI localization/translation part of your app.

Whatever regional options the system is configured to have will be the "Current" values in your .NET app.

Often times they are both the same. But on my system they would be different: I prefer my numbers and dates in the German format, so the CurrentCulture would be German, but I also prefer all my applications in English, so the CurrentUICulture would be English.

There is a nice article on the topic: Sorting it all Out: Why we have both CurrentCulture and CurrentUICulture

like image 162
Tomalak Avatar answered Oct 19 '22 15:10

Tomalak


This is a simple trick I use to remember which one to use:

(date, currency, double).tostring = CurrentCulture  resource.fr-CA.resx file = currentUICulture 
like image 35
foxontherock Avatar answered Oct 19 '22 15:10

foxontherock