This documentation is archived and is not being maintained.

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 CurrentUICulture. For more information, see the examples provided later in this topic.

Note   Changing the culture of Thread.CurrentThread requires a SecurityPermission with the SecurityPermissionFlag,ControlThread set. Manipulating threads is dangerous because of the security state associated with threads. Therefore, this permission should be given only to trustworthy code, and then only as necessary. You cannot change a thread's culture in semi-trusted code.

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

Developing World-Ready Applications | CultureInfo.CurrentUICulture Property | Using the CurrentCulture Property | Using the InvariantCulture Property