Partager via


How to Set CurrentCulture, CurrentUICulture

Explicitly

p Thread.CurrentThread.CurrentUICulture = new CultureInfo(“ja”)

p Thread.CurrentThread.CurrentCulture = new CultureInfo(“ja-JP”)

p Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages(0))

p Within an individual API that takes a culture

n Str = DateTime.Now.ToString(cultureInfo);

 You must use a specific culture to initialize the CurrentCulture property. The CurrentCulture property expects a culture that is associated with both a language and a region, such as ("en-US") for English in the United States.

If you only have access to a neutral culture, you can create a CultureInfo object in the format that the CurrentCulture property expects, using the CultureInfo.CreateSpecificCulture Method. This method maps a neutral culture to the default specific culture it is associated with, and then creates a CultureInfo object that represents that specific culture.

Link to the Globalization supprot in Microsoft.Net Framework-Globalization Support in Microsoft .NET Framework

Comments