Partilhar via


Using the CurrentUICulture Property 

The CultureInfo.CurrentUICulture property is a per-thread setting that returns the current user interface culture. This property is used by the ResourceManager class to look up culture-specific resources at run time. You can use a neutral or specific culture, or the InvariantCulture to set the CurrentUICulture property. You can use the Thread.CurrentThread property to set CurrentCulture. For more information, see the examples provided later in this topic.

Explicitly Setting the CurrentUICulture Property

You can set the CurrentUICulture property explicitly in your application's code. The following code example sets the CurrentUICulture property to the neutral culture "de" for German.

Thread.CurrentThread.CurrentUICulture = new CultureInfo("de")
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de");

You can also set the CurrentUICulture property to a specific culture. The following code example sets the CurrentUICulture property to the specific culture "de-DE" for German in Germany.

Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE")
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE");

Implicitly Setting the CurrentUICulture Property

If the CurrentUICulture property is not set explicitly in an application's code, it is set by default when the application starts. It is set by the GetUserDefaultUILanguage function on Windows 2000 and Windows XP Multilingual User Interface (MUI) products where the end user can set their UI language. If the user's UI language is not set, it will be set by the system-installed language, which is the language of the operating system's resources.

See Also

Reference

CultureInfo.CurrentUICulture Property

Concepts

Using the CurrentCulture Property
Using the InvariantCulture Property

Other Resources

Encoding and Localization