Get currency from current culture?

Is there a way to dynamically retrieve current information from application culture settings? Basically, if a user has established a culture for the USA, I want to know that the currency is dollars, or if they are set in the UK, I want the pound, etc. Etc.

This means that I can send this information to PayPal when the payment is made.

+47
c # currency cultureinfo
May 4 '10 at 6:01
source share
7 answers

Use the RegionInfo.ISOCurrencySymbol property. For example:

var ri = new RegionInfo(System.Threading.Thread.CurrentThread.CurrentUICulture.LCID); Console.WriteLine(ri.ISOCurrencySymbol); 

Output: "USD"

+72
May 04 '10 at 7:22 a.m.
source share

You can get the symbol from CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol , but I doubt that is enough; You may need to keep a separate list for each crop. Or just let the user tell you what they want to pay for (for example, they can be away from home, etc., Therefore, the PC culture in some hotel lounge is not what is on their credit card).

+38
May 04 '10 at 6:15 a.m.
source share

Once you have a CultureInfo ci object, you can ask, for example,

 ci.NumberFormat.CurrencySymbol 

For the current culture, you simply do

 CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol 
+24
May 04 '10 at 6:07 a.m.
source share
 string isoCurrencySymbol = RegionInfo.CurrentRegion.ISOCurrencySymbol; 
+3
Oct 27 '11 at 10:08
source share

Basically you can use the CultureInfo class

 CultureInfo ci = new CultureInfo(UICulture); var symbol = ci.NumberFormat.CurrencySymbol; 
+2
May 04 '10 at 6:07 a.m.
source share
  public static string GetCurrencySymbol(string currency) { if (currency == null) return ""; if (currency == "") return ""; int i = 0; var regionInfo = new RegionInfo(System.Threading.Thread.CurrentThread.CurrentUICulture.LCID); foreach (var cultureInfo in CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures)) { if (!cultureInfo.Equals(CultureInfo.InvariantCulture)) { var regionCulture = new RegionInfo(cultureInfo.LCID); if(regionCulture.ISOCurrencySymbol == currency) { //list.Add(regionCulture); regionInfo = regionCulture; } } } 
+1
Dec 13 '10 at 7:55
source share

http://help.outlook.com/en-us/140/system.globalization.regioninfo.currencynativename(VS.85).aspx

You will need RegionInfo.CurrencyNativeName, RegionInfo.CurrencyEnglishName or RegionInfo.ISOCurrencySymbol

0
Jun 02 '10 at
source share



All Articles