Accessing “Measurement System” unit names (kg/lb, m/in, etc) in C#

我怕爱的太早我们不能终老 提交于 2019-11-30 19:09:01

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;

@GenericTypeTea is right about the RegionInfo being the place to look.

Additionally F# contains a lot of features for working with units of measure. It might make sense to build some of what you need in F# and call it from C#.

See this blog post and the subsequent posts for information about F# and units of measure.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!