Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Currency abbreviation (EUR, USD, GBP) convert to currency symbol (€, $, £)

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

I hope someone can help me.

like image 973
Khal Avatar asked Mar 02 '11 10:03

Khal


1 Answers

You can run through all cultures till 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;
}
like image 195
Søren Ullidtz Avatar answered Sep 29 '22 08:09

Søren Ullidtz