Use UnitAbbreviationsCache.Default to extend a abbreviation #1415
-
UseCaseI'm using a multimeter which returns IssueWhen using [Fact]
public void ExtendUnitAbbreviationsCacheTest()
{
const string valueToParse = "4.00 MΩ";
var expectedQuantity = ElectricResistance.FromMegaohms(4);
var formatProvider = CultureInfo.InvariantCulture;
Assert.Equal(ElectricResistance.Parse(valueToParse, formatProvider), expectedQuantity);
UnitAbbreviationsCache.Default.MapUnitToAbbreviation(ElectricResistanceUnit.Ohm, formatProvider, "Ω", "Ohm");
// -> The input string '4.00 M' was not in a correct format.
Assert.Equal(ElectricResistance.Parse(valueToParse, formatProvider), expectedQuantity);
} QuestionIs there any other solution, to extend a unit map with a custom abbreviation, instead of using my own |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Late reply, sorry. What version is this? |
Beta Was this translation helpful? Give feedback.
Late reply, sorry.
What version is this?
Your code works for me on 5.58 and 6.0.0-pre012.