0

I want to pass the list of all currency symbols to property in c# so instead of manualy giving list of of currency code is there any way to get the available list of currency code or currency symbols using CultureInfo.

Mohini Jamdade
  • 478
  • 1
  • 6
  • 17
  • Did you look at the documentation? – phoog Sep 30 '15 at 16:56
  • yes but i didnt got anything to get the list of currency code using cultureInfo – Mohini Jamdade Sep 30 '15 at 16:57
  • 2
    http://stackoverflow.com/questions/12373800/3-digit-currency-code-to-currency-symbol (can be found by searching for title - https://www.bing.com/search?q=Get+list+of+currency+code+using+CultureInfo) provides all inforamtion you need. – Alexei Levenkov Sep 30 '15 at 17:06

1 Answers1

6

Note that this may not be completely possible, because a given machine may not have all cultures installed.

That being said, you can load cultures using the GetCultures method

CultureInfo.GetCultures(CultureTypes.AllCultures);

Adding in a little bit of LINQ to provide a selection...

// string[] rather than char[] due to NumberFormatInfo.CurrencySymbol returning a string
string[] currencySymbols = 
    CultureInfo.GetCultures(CultureTypes.AllCultures)

        // This will select the currency symbol for each given Culture
        // Because cultures define a host of number formatting rules, you have to dig into the NumberFormat property to get Currency Symbol
        .Select(culture => culture.NumberFormat.CurrencySymbol)

        // Since some cultures use the same currency symbol, this will trim out duplicates
        .Distinct()

        // Enumerate this to an array in order to avoid reevaluating the entire process every time it's accessed
        .ToArray();
David
  • 10,458
  • 1
  • 28
  • 40