Skip to main content

How to: Convert Between Metric Prefixes

The Unit Conversion API includes a special converter that helps you convert between different metric prefixes. The following code illustrates how to display a pressure that is equal to 760 millimeters of mercury in hectopascals.

using DevExpress.UnitConversion;
using System.Diagnostics;
            // The pressure value is set to 760 mmHg.
            QuantityValue<Pressure> pressure = (760).MmHg();
            // Since it is a quantity value, it should be transformed to a proper measurement unit
            // to obtain a value for display or for comparison.
            // The pressure is obtained in Pascals and then converted into hectoPascals.
            MetricUnitsConverter prefixConverter = new MetricUnitsConverter();
            double pressure_in_hPa = prefixConverter.Convert(pressure.ToPascals(), MetricPrefix.None, MetricPrefix.Hecto);