gpt4 book ai didi

c# - 寻找显示中带有货币符号的世界货币枚举

转载 作者:行者123 更新时间:2023-12-04 13:43:37 24 4
gpt4 key购买 nike

我正在寻找一个枚举或其他可以用于下拉列表的东西,该下拉列表将显示货币名称(例如美元)及其符号(例如 $),其中值是货币代码,例如 '美元'

我不想输入 100+

像这样的东西

enum Currency {

[Display(Name = "United States Dollar $")]
USD,
[Display(Name = "Mexican Peso $")]
MXN,
[Display(Name = "Japanese Yen ¥")]
JPY
}

最佳答案

这将为您提供所有可用货币的列表:

HashSet<string> hashSet = new HashSet<string>();
foreach (CultureInfo item in CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures))
hashSet.Add(item.NumberFormat.CurrencySymbol);

foreach (string currency in hashSet)
Console.WriteLine(currency);

关于c# - 寻找显示中带有货币符号的世界货币枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52961117/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com