我正在尝试获取加纳(en-GB)和其他一些国家的ISO名称和货币,但没有显示任何内容。当我运行代码时,这就是我得到的。
using System;
using System.Globalization;
class Currency
{
public static void Main()
{
var cul = CultureInfo.GetCultures(CultureTypes.AllCultures);
foreach (var curr in cul)
{
Console.WriteLine(curr.TwoLetterISOLanguageName + " "
+ curr.EnglishName + " "
+ curr.NumberFormat.CurrencySymbol.ToString());
}
}
}
SPULED RESULT
nn Norwegian, Nynorsk (Norway) kr
pt Portuguese (Portugal) ?
sr Serbian (Latin, Serbia and Montenegro (Former)) Din.
sv Swedish (Finland) ?
az Azeri (Cyrillic, Azerbaijan) ???.
dsb Lower Sorbian (Germany) ?
se Sami, Northern (Sweden) kr
ga Irish (Ireland) ?
ms Malay (Brunei Darussalam) $
uz Uzbek (Cyrillic, Uzbekistan) ???
bn Bengali (Bangladesh) ?
mn Mongolian (Traditional Mongolian, PRC)
iu Inuktitut (Latin, Canada) $
tzm Tamazight (Latin, Algeria) DZD
quz Quechua (Ecuador) $
ar Arabic (Egypt) ?.?.?
zh Chinese (Traditional, Hong Kong S.A.R.) HK$
de German (Austria) ?
en English (Australia) $
es Spanish (Spain, International Sort) ?
fr French (Canada) $
sr Serbian (Cyrillic, Serbia and Montenegro (Former)) ???.
se Sami, Northern (Finland) ?
quz Quechua (Peru) S/.
答案 0 :(得分:1)
这对我有用:
var culture = CultureInfo.GetCultureInfo("en-GB");
Console.WriteLine(culture.TwoLetterISOLanguageName);
Console.WriteLine(culture.NumberFormat.CurrencySymbol);
您应该记住,您的控制台窗口无法同时显示所有文化。尝试将它们写入文本文件,然后检查它的内容:
var cul = CultureInfo.GetCultures(CultureTypes.AllCultures);
var lines = cul
.Select(x => string
.Join(" ", x.TwoLetterISOLanguageName, x.EnglishName, x.NumberFormat.CurrencySymbol));
File.WriteAllLines("cultures.txt",lines);
答案 1 :(得分:0)
我要做的是根据所选文化获取货币,如:
en-US - $ en-GB - 磅
但全球化命名空间中定义的某些国家/地区没有货币。