访问"测量系统"单位名称(公斤/磅,M /在等)在C# [英] Accessing "Measurement System" unit names (kg/lb, m/in, etc) in C#

查看:152
本文介绍了访问"测量系统"单位名称(公斤/磅,M /在等)在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows允许测量系统的配置,公制有没有使用此设置来读取在C#(略)单位名称的方式?

Windows allows configuration of Measurement system to Metric or U.S. Is there a way to use this setting to read (abbreviated) unit names in C#?

如显示在公制重量时我想说明公斤我想说明。同样,对于长度,体积等。

e.g. when displaying a weight in Metric I want to show kg but in U.S. I want to show lb. Similarly for length, volume, etc.

我已经看了SystemInformation,CultureInfo的,配置和全球化,但没有看到任何明显。我错过了什么还是我找错了地方?

I've looked at SystemInformation, CultureInfo, Configuration, and Globalization, but didn't see anything obvious. Did I miss something or am I looking in the wrong place?

推荐答案

我相信你能做的最好是确定你的文化是公制或不是,然后自己处理。我不认为有任何内置的格式?我可能是错的,但我找不到它的任何地方的任何引用

I believe the best you can do is to determine if your culture is metric or not and then handle it yourself. I don't think there's any built in formatting? I may be wrong though, but I cannot find any reference to it anywhere.

这将允许你确定你的文化是公制或不:

This will allow you to determine if your culture is metric or not:

    CultureInfo culture = new CultureInfo("en-GB");
    RegionInfo regionInfo = new RegionInfo(culture.LCID);
    bool isMetric = regionInfo.IsMetric;

这篇关于访问"测量系统"单位名称(公斤/磅,M /在等)在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆