Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Standard equivalent of Thread.CurrentCulture

With the full .NET framework, you can get/set the current thread's culture and UI culture using:

Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;

I'm porting a library to netstandard1.n (n is to be determined) and discovered the Thread class does not define CurrentCulture nor CurrentUICulture.

Is there an alternative API for this?

like image 814
Drew Noakes Avatar asked Oct 30 '16 17:10

Drew Noakes


People also ask

What is difference between CurrentCulture and CurrentUICulture?

CurrentCulture – Tells you the user's current locale, as set in the Region applet. I.e.: Where is the user located? CurrentUICulture – Tells you the native language of the version of Windows that is installed.

What is CultureInfo CurrentCulture in C#?

The CultureInfo. CurrentCulture property is a per-thread setting; that is, each thread can have its own culture. You get the culture of the current thread by retrieving the value of the CultureInfo. CurrentCulture property, as the following example illustrates. C# Copy.

How do I declare CultureInfo in VB net?

How to CultureInfo in VB.NET. The CultureInfo class specifies a unique name for each culture, based on RFC 4646. The name is a combination of an ISO 639 two-letter lowercase culture code associated with a language and an ISO 3166 two-letter uppercase subculture code associated with a country or region.

How do you change the current UI culture?

To change the current UI culture, you assign the CultureInfo object that represents the new UI culture to the Thread. CurrentThread. CurrentUICulture property.


1 Answers

Use CultureInfo's static members instead:

CultureInfo.CurrentCulture = culture;
CultureInfo.CurrentUICulture = culture;
like image 115
Drew Noakes Avatar answered Oct 07 '22 01:10

Drew Noakes