views:

326

answers:

5

Is there a way to get current information dynamically from the apps culture settings? Basically if the user has set the culture to US I want to know the currency is dollars, or if they have it set to UK I want to pound sterling etc... etc..

This is so I can send this information to PayPal when a payment is being made

+1  A: 

Once you have the CultureInfo ci object, you can ask such as

ci.NumberFormat.CurrencySymbol

For current culture, you will simply do

CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol
Fadrian Sudaman
Not necessariy good enough as the currency SYMBOL may not be unique.
TomTom
A: 

You can basically use CultureInfo class

CultureInfo ci = new CultureInfo(UICulture);
var symbol = ci.NumberFormat.CurrencySymbol;
Jan Remunda
Not good enough - sorry. THe currency symbol is not the currency - there is no requirement for that being unique.
TomTom
+4  A: 

You can get the symbol from CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol, but I doubt this is enough; you may need to maintain a separate list per culture. Or just let the user tell you what they want to pay in (for example, they might be away from home, etc, so the culture of the PC in some hotel lounge isn't what is on their credit card)

Marc Gravell
+5  A: 

Use the RegionInfo.ISOCurrencySymbol property. For example:

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

Output: "USD"

Hans Passant
I think paypal expects "USD", he is looking for ISO Currency Codes..
Akash Kava
This should work perfectly! I'll try it this afternoon and mark as the answer if it works :) Thanks
leen3o
A: 

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

You'll want the RegionInfo.CurrencyNativeName, RegionInfo.CurrencyEnglishName or RegionInfo.ISOCurrencySymbol

Jeroen