Skip to content

Commit a7c52a8

Browse files
authored
Update README.md
1 parent efaf685 commit a7c52a8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ See [Upgrading from 3.x to 4.x](https://github.com/angularsen/UnitsNet/wiki/Upgr
3030
* [Operator overloads](#operator-overloads) for arithmetic on quantities
3131
* [Parse and ToString()](#culture) supports cultures and localization
3232
* [Dynamically parse and convert](#dynamic-parsing) quantities and units
33-
* [Custom units](#custom-units)
33+
* [Extensible with custom units](#custom-units)
3434
* [Example: Creating a unit converter app](#example-app)
3535
* [Example: WPF app using IValueConverter to parse quantities from input](#example-wpf-app-using-ivalueconverter-to-parse-quantities-from-input)
3636
* [Precision and accuracy](#precision)
3737
* [Serialize with JSON.NET](#serialization)
38-
* Extensible with [custom units](https://github.com/angularsen/UnitsNet/wiki/Extending-with-Custom-Units)
3938
* [Contribute](#contribute) if you are missing some units
4039
* [Continuous integration](#ci) posts status reports to pull requests and commits
4140
* [Who are using this?](#who-are-using)
@@ -238,15 +237,15 @@ Read more at [Extending-with-Custom-Units](https://github.com/angularsen/UnitsNe
238237
UnitAbbreviationsCache.Default.MapUnitToDefaultAbbreviation(HowMuchUnit.Some, "sm");
239238
UnitAbbreviationsCache.Default.GetDefaultAbbreviation(HowMuchUnit.Some); // "sm"
240239
UnitParser.Default.Parse<HowMuchUnit>("sm"); // HowMuchUnit.Some
240+
```
241241

242+
#### Convert between units of custom quantity
243+
```c#
242244
var unitConverter = UnitConverter.Default;
243245
unitConverter.SetConversionFunction<HowMuch>(HowMuchUnit.Lots, HowMuchUnit.Some, x => new HowMuch(x.Value * 2, HowMuchUnit.Some));
244246
unitConverter.SetConversionFunction<HowMuch>(HowMuchUnit.Tons, HowMuchUnit.Lots, x => new HowMuch(x.Value * 10, HowMuchUnit.Lots));
245247
unitConverter.SetConversionFunction<HowMuch>(HowMuchUnit.Tons, HowMuchUnit.Some, x => new HowMuch(x.Value * 20, HowMuchUnit.Some));
246-
```
247248

248-
#### Convert between units of custom quantity
249-
```c#
250249
var from = new HowMuch(10, HowMuchUnit.Tons);
251250
IQuantity Convert(HowMuchUnit toUnit) => unitConverter.GetConversionFunction<HowMuch>(from.Unit, toUnit)(from);
252251

0 commit comments

Comments
 (0)