Currency Library [closed]
-
13-09-2019 - |
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?
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
- Reporting is much easier as you can join on this table and format the output as necessary
- Changes in the sector can be catered for
- 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).