StayOnTarget
StayOnTarget

Reputation: 13007

How to find out the default units of measure system (imperial or metric) in Windows / .NET?

In Windows, ideally using the .NET framework, is there a way to determine the normal units of measure (e.g., SI/metric vs. Imperial/US/English)? If possible I assume this would be related to the PC's locale settings in some way.


Similar to:

Upvotes: 0

Views: 435

Answers (1)

CodeCaster
CodeCaster

Reputation: 151604

There's the IsMetric property on the RegionInfo class.

var us = new RegionInfo("US");
Console.WriteLine($"Is {us.Name} Metric: {us.IsMetric}");

var nl = new RegionInfo("NL");
Console.WriteLine($"Is {nl.Name} Metric: {nl.IsMetric}");

Prints:

Is US Metric: False
Is NL Metric: True

Upvotes: 3

Related Questions