为什么没有文化枚举?
您好,
我想知道为什么 C# 中没有预先设置的文化枚举? 既然文化永远不会改变,而且总是像“nl-NL、en-GB、en-US”……为什么不为其创建一个枚举以使事情变得简单一点呢?
[编辑]
如前所述,文化确实会改变……但不是全部。为什么不创建一个枚举/类类型来保存所有文化并提供添加/更改它们的可能性?
Greetings,
I was wondering why there isn't a pre-set enum for cultures in C#?
Since the cultures never change and are always like "nl-NL, en-GB, en-US".. why not make a enum for it to make things just a little bit easy'r ?
[edit]
As stated cultures do change.. but not all. Why not make a enum / class type which holds all the cultures and gives the possibility to add / change them ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不是吗? 本文(Microsoft .NET Framework 4:全球化的新变化) 不同意。仅在过去五年中,塞尔维亚地区就发生了很大变化,催生了新的文化。
此外,我认为枚举本身没有意义。 CultureInfo 不仅仅是一个名称,查找提供了更大的灵活性和独立性,不受任何政治变化的影响,其中的变化比我们通常意识到的要多得多。
Don't they? This article (Microsoft .NET Framework 4: What is New in Globalization) disagrees. In the past 5 years alone, a lot has changed in the region of Serbia for example, leading to new Cultures.
Also, I guess an enum itself does not make sense. A CultureInfo is much more than just a name, and a lookup offers more flexibility and independence from any political changes, of which there are many more than we usually realize.
枚举在编译时是固定的。
但文化集在运行时会有所不同:
Enumerations are fixed at compile time.
But the set of cultures varies at runtime:
他们确实在改变,尽管很慢。无论如何,它们早于 C#,因此此时将它们变成枚举将是一件很麻烦的事情。就像我在 postForth 中所做的那样,将 POSIX 系统调用放入枚举中,但当我这样做时就知道这是错误的。
They do change, albeit slowly. In any case, they predate C#, so making them into an enum at this point would be kludgery. Like making POSIX system calls into an enum, which I did in postForth, but knew it was wrong when I did it.
除了按照其他人的建议进行更改之外,您还可以创建自己的文化 并且它们显然不会出现在枚举中,因为您无法向其中添加项目。
In addition to them changing, as suggested by others, you can create your own cultures and they would be conspicuously absent from the enum since you can't add items to it.