Finding the current culture settings using the CultureInfo class in .NET C#
December 25, 2016 Leave a comment
Finding the the culture settings – the locale – of a thread is straightforward in .NET:
CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
We extract the current culture from the current thread. The CultureInfo class holds a number of properties to extract information from it. Examples:
string cultureName = cultureInfo.Name; string cultureDisplayName = cultureInfo.DisplayName; string nativeName = cultureInfo.NativeName; string englishName = cultureInfo.EnglishName; string cultureAbbreviation = cultureInfo.TwoLetterISOLanguageName;
As my computer is set to run with Swedish settings I got the following values from top to bottom: