Question

I am looking for a .Net class/library to use with currency acronyms in the same way the TimeZoneInfo class works with timezones.

I need to populate a drop down list with these acronyms and store the result in a databse. This value will be used to retrieve up to date exchange rates from the web at a later stage.

Any ideas?

Was it helpful?

Solution

CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
IEnumerable<string> currencySymbols = cultures.Select<CultureInfo, string>(culture => new RegionInfo(culture.LCID).ISOCurrencySymbol);

Is it what you are looking for?

OTHER TIPS

You might be better off generating the list yourself and putting it in a database along with related information. I've used this approach fairly successfully

Country  Currency Name Symbol Code

USA  US Dollar  $ USD

There are a couple of benefits

  1. Reporting is much easier as you can join on this table and format the output as necessary
  2. Changes in the sector can be catered for
  3. Complicated scenarios such as countries supporting multiple currencies can be handled

Well, can you query this list from the web-service that you will be using for exchange rates?

Fundamentally, it is a much simpler list than TimeZoneInfo (which has to handle lots of complexities) - a simple enum or hard-coded/database list should suffice? And it does change periodically (see: EUR).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top