Currency Symbol
-
How can I get the currency symbol from just the ISO 4217 standard 3-letter code.
CAD = $ USD = $ GBP = £ YEN = ¥
I tried creating a RegionInfo by stripping out the first two characters of the 3-letter code but is doesn't work for all cases. Any ideas? -
How can I get the currency symbol from just the ISO 4217 standard 3-letter code.
CAD = $ USD = $ GBP = £ YEN = ¥
I tried creating a RegionInfo by stripping out the first two characters of the 3-letter code but is doesn't work for all cases. Any ideas?Stripping the first two chars of the code doesn't work because YEN => YE, but the country is JAPAN, code JP, BTW the ISO 4217 code for YEN is JPY, no YEN. You can use a HashTable, and fill it at start of your application, this way: HashTable ht = new HashTable(); foreach (CultureInfo ci in CultureInfo.GetCultures( CultureTypes.AllCultures ) ) { RegionInfo ri = new RegionInfo(ci.LCID); ht[ri.ISOCurrencySymbol] = ri.CurrencySymbol; } Later you access the symbol this way: string sym = (string) ht[isocode]; Eduardo Diaz site | english blog | spanish blog
-
Stripping the first two chars of the code doesn't work because YEN => YE, but the country is JAPAN, code JP, BTW the ISO 4217 code for YEN is JPY, no YEN. You can use a HashTable, and fill it at start of your application, this way: HashTable ht = new HashTable(); foreach (CultureInfo ci in CultureInfo.GetCultures( CultureTypes.AllCultures ) ) { RegionInfo ri = new RegionInfo(ci.LCID); ht[ri.ISOCurrencySymbol] = ri.CurrencySymbol; } Later you access the symbol this way: string sym = (string) ht[isocode]; Eduardo Diaz site | english blog | spanish blog
thank you