【问题标题】:Wrong country code from CurrentCultureCurrentCulture 的国家代码错误
【发布时间】:2015-04-27 10:41:05
【问题描述】:

我对 CurrentCulture(C#、Windows 应用商店应用)有疑问。

我需要获取用户国家代码(将默认国家设置为我的国家列表视图)。

我用过代码:

string currentCountryCode = CultureInfo.CurrentCulture.Name;

if (currentCountryCode != null && currentCountryCode.Length == 5)
{
    currentCountryCode = currentCountryCode.ToLower().Substring(3);
}

我的问题是:为什么我得到错误的国家代码(我得到“我们”,但我的计算机区域设置中有拉脱维亚)?

【问题讨论】:

  • 您使用什么服务来获取国家代码和标志?

标签: c# windows-store-apps cultureinfo


【解决方案1】:

CultureInfo.CurrentCulture 不会告诉您您所在的国家/地区。它会告诉您您选择的文化。文化位于“区域和语言”对话框的“格式”选项卡中,而不是“位置”选项卡中。

如果您真的想要“位置”设置,请查看此答案:https://stackoverflow.com/a/10085592/2394945 不幸的是,您似乎必须去注册表才能获得它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-16
    • 1970-01-01
    • 1970-01-01
    • 2017-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多