Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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);
            Debug.WriteLine(pressure_in_hPa);