Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Density - kg/l vs kg/dm3 #1508

Closed
blahetal opened this issue Jan 31, 2025 · 2 comments
Closed

Density - kg/l vs kg/dm3 #1508

blahetal opened this issue Jan 31, 2025 · 2 comments

Comments

@blahetal
Copy link

Hello
Just wanted to ask why density in kg/l is preffered over kg/dm3? Is it possible to define an alias kg/dm3 so that is recognised by UnitsNet as kg/l and thus processed the samy way (parsing, converting, etc)?
It is defined here.

Regards
Libor

@lipchev
Copy link
Collaborator

lipchev commented Jan 31, 2025

I don't know why- but there does seem to be a bias against the decimeter (I remember it used to be one of my favorite units back in primary school).

If you're only interested in the abbreviation, you could map it using the

  • UnitAbbreviationsCache.MapUnitToAbbreviation: this should work if you only want to be parsing units such as "kg/dm3"
  • UnitAbbreviationsCache.MapUnitToDefaultAbbreviation: this would make it also be the default ToString abbreviation for the given unit

If you really need to have KillogramPerCubicDecimeter as a separate enum value, you'd have to go the PR route: we've already covered the cubic meter, centimeter, millimeter, foot, inch and yard - what's another decimeter.. 😄

@blahetal
Copy link
Author

blahetal commented Jan 31, 2025

thanks, I will try MapUnitToAbbreviation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants