为什么没有文化枚举?

发布于 2024-11-02 17:22:20 字数 184 浏览 6 评论 0原文

您好,

我想知道为什么 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

送你一个梦 2024-11-09 17:22:20

“因为文化永远不会改变”

不是吗? 本文(Microsoft .NET Framework 4:全球化的新变化) 不同意。仅在过去五年中,塞尔维亚地区就发生了很大变化,催生了新的文化。

在现实世界中,全球化信息不断变化,因为当地市场的文化发展,因为新标准频繁更新文化敏感信息,或者因为微软发现了有关不同市场的更准确信息或扩展到更多市场.

Microsoft .NET Framework 4 至少支持 354 种文化,而之前版本中至少支持 203 种文化。其中许多文化都是中性文化,添加它们是为了完成根中性文化的父链。

例如,三个因纽特语中立语被添加到现有的文化因纽特语(音节,加拿大)和因纽特语(拉丁语,加拿大)

此外,我认为枚举本身没有意义。 CultureInfo 不仅仅是一个名称,查找提供了更大的灵活性和独立性,不受任何政治变化的影响,其中的变化比我们通常意识到的要多得多。

"Since the cultures never change"

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.

In the real world, the globalization information is constantly changing because of cultural developments in the local markets, because of new standards which update the culture sensitive information frequently, or because Microsoft finds more accurate information about different markets or expands into more markets.

Microsoft .NET Framework 4 supports a minimum of 354 cultures compared to a minimum of 203 cultures in the previous release. Many of those cultures are neutrals that were added to complete the parent chain to the root neutral culture.

For example, three Inuktitut neutrals were added to the already existing cultures Inuktitut (Syllabics, Canada) and Inuktitut (Latin, Canada)

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.

作业与我同在 2024-11-09 17:22:20

枚举在编译时是固定的。

但文化集在运行时会有所不同:

  • 不同的操作系统版本支持不同的文化
  • 操作系统更新(服务包、语言界面包等)可以添加文化
  • 更高版本的 .NET 版本支持更多文化(为一个版本构建程序集并将其与另一个版本一起使用) )。

Enumerations are fixed at compile time.

But the set of cultures varies at runtime:

  • Different OS versions support different cultures
  • OS updates (Service Packs, Language Interface Packs, ...) can add cultures
  • Later .NET versions support more cultures (build assembly for one version and use it with another).
留一抹残留的笑 2024-11-09 17:22:20

他们确实在改变,尽管很慢。无论如何,它们早于 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.

陌若浮生 2024-11-09 17:22:20

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文