c# - Get list of currency code using CultureInfo -
this question has answer here:
- 3 digit currency code currency symbol 7 answers
i want pass list of currency symbols property in c# instead of manualy giving list of of currency code there way available list of currency code or currency symbols using cultureinfo.
note may not possible, because given machine may not have cultures installed.
that being said, can load cultures using getcultures method
cultureinfo.getcultures(culturetypes.allcultures);
adding in little bit of linq provide selection...
// string[] rather char[] due numberformatinfo.currencysymbol returning string string[] currencysymbols = cultureinfo.getcultures(culturetypes.allcultures) // select currency symbol each given culture // because cultures define host of number formatting rules, have dig numberformat property currency symbol .select(culture => culture.numberformat.currencysymbol) // since cultures use same currency symbol, trim out duplicates .distinct() // enumerate array in order avoid reevaluating entire process every time it's accessed .toarray();
Comments
Post a Comment