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 |
Answered by
angularsen
Sep 29, 2024
Replies: 1 comment 3 replies
|
Late reply, sorry. What version is this? |
3 replies
Answer selected by
angularsen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Late reply, sorry.
What version is this?
Your code works for me on 5.58 and 6.0.0-pre012.