简体   繁体   中英

How to get the culture of an IFormatProvider

i am converting strings to values using a culture specified to me as a IFormatProvider .

i am trying to figure out which culture they gave me.

i realize that IFormatProvider doesn't necessarily have to correspond to a System.Globalization.Culture , but it did.

So how can i get its name?

The CultureInfo class implements IFormatProvider so you may try casting:

IFormatProvider provider = ...
CultureInfo ci = provider as CultureInfo;
if (ci != null)
{
    string name = ci.DisplayName;
    ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM