访问"测量系统"单位名称(公斤/磅,M /在等)在C# [英] Accessing "Measurement System" unit names (kg/lb, m/in, etc) in 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屋!