如何制作所有文化的下拉列表(但不重复)
我正在尝试制作 2 个下拉列表。
第一个提供所有文化(但不重复)。 示例:英语、西班牙语、菲律宾语
从顶部列表中选择后,底部列表将显示任何特定类型。
我现在使用此代码作为我的首要列表。
foreach (CultureInfo cultureInfo in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
但是它不显示菲律宾语(菲律宾) 我不想使用 GetCultures(CultureTypes.AllCultures)) 因为它一次显示太多。
看来我可能需要将 NeutralCultures 加载到 IList 中。 然后迭代 AllCultures 以确保其 ThreeLetterISOLanguageName 位于列表中,如果没有添加它。
这有最佳实践吗?
谢谢
I'm trying to make 2 dropdown lists.
The top one offers all cultures, (but no repeats).
Example: English, Spanish, Filipino
After selecting from the top list the bottom list will show any specific types.
I right now I use this code for my top list.
foreach (CultureInfo cultureInfo in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
However it does not show Filipino (Philippines)
I'd rather not use GetCultures(CultureTypes.AllCultures)) because it shows too many at once.
It seems like I may need to load NeutralCultures into an IList.
Then iterate through AllCultures to make sure it's ThreeLetterISOLanguageName is in the list, if not add it.
There a best practice for this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看不同
CultureTypes
值。它告诉您每个内容都包含什么。我想您想要除特定文化之外的所有内容?您可以将所有非特定区域性组合成一个集合,也可以获取所有区域性并排除特定区域性。第二种方法最容易在 LINQ 中表达:
尽管似乎由于
CultureTypes
具有 flags 属性,我们也可以在获取它们时屏蔽掉SpecificCultures
。Look at the reference for the different
CultureTypes
values. It tells you what is included for each.I guess you want everything that's in all but the specific cultures? You could either combine all non-specific cultures into a set or get all cultures and exclude the specific ones. The second approach would be easiest to express in LINQ:
Though it seems that since
CultureTypes
has the flags attribute, we could also just mask out theSpecificCultures
when getting them.