Humanizer icon indicating copy to clipboard operation
Humanizer copied to clipboard

MetricNumeralExtensions.ToMetric is obsolete, use MetricNumeralFormats?

Open SmartieCodes opened this issue 5 years ago • 3 comments

We've upgraded 2.8.26 from to 2.11.10 and now get the following warning:

'MetricNumeralExtensions.ToMetric(double, bool, bool, int?)' is obsolete: 'Please use overload with MetricNumeralFormats'

Are there any examples on how to use MetricNumeralFormats, I cannot find any documentation.

This is our current code:

.ToMetric(false, true, 2);

SmartieCodes avatar Jul 21 '21 08:07 SmartieCodes

@LeahPike You have to use:

var format = MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName;
var decimals = 2;
foo.ToMetric(format, decimals);

source: MetricNumeralTests and MetricNumeralFormats

As the original creator of the feature (with all the boolean), I love this choice made by the Humanizr's team. It is clearer like this :)

aloisdg avatar Jul 21 '21 12:07 aloisdg

Thank you :)

SmartieCodes avatar Jul 23 '21 13:07 SmartieCodes

You are welcome. I added this Q&A to stackoverflow: https://stackoverflow.com/questions/68542840/metricnumeralextensions-tometric-is-obsolete-use-metricnumeralformats/68542841#68542841

aloisdg avatar Jul 27 '21 12:07 aloisdg