Currency abbreviation (EUR, USD, GBP) is converted into a currency symbol (€, $, £)

I have a dropdownbox with abbreviations such as EUR, USD, GBP and for all other currencies. I would like to use some C # .Net functionality / method where I can insert a currency abbreviation and it returns the currency symbol (€, $, £).

Hope someone can help me.

+6
c # currency symbol
source share
6 answers

There is nothing specific in this area, but you could solve it using the Dictionary of abbreviations and currency symbols.

+3
source share

You can go through all cultures until you find a match:

public string GetCurrencySymbolFromAbbreviation(string abbreviation) { foreach (CultureInfo nfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { RegionInfo region = new RegionInfo(nfo.LCID); if (region.ISOCurrencySymbol == abbreviation) { return region.CurrencySymbol; } } return null; } 
+3
source share

I don’t know anything built into the framework, but if you have a list of currencies you are interested in, it sounds like an ideal place to use Dictionary<string, string> or, possibly, Dictionary<string, char> (I don’t know if there are multi-character characters, but I won’t be surprised).

+2
source share

I was looking for some kind of dynamic solution and I found this:

 RegionInfo regionInfo = (from culture in CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures) where culture.Name.Length > 0 let region = new RegionInfo(culture.LCID) where String.Equals(region.ISOCurrencySymbol, "EUR", StringComparison.InvariantCultureIgnoreCase) select region).First(); string currencySymbol = regionInfo.CurrencySymbol; 
+2
source share

You can use arraylist / hashtable to store EUR, USD, GBP with its corresponding unicode 0x20A0 [EUR], 0x0024 [USD] & 0x00A3 [GBP].

You can retrieve data from this array / hash table when required or raise the onChange event.

+1
source share

A simple way is to use a database with a currency, a currency symbol. When you select "Currency Name", it will automatically select the symbol "Currency" and you can use it.

0
source share

All Articles