UnitsNet
UnitsNet copied to clipboard
ToString() with the closest unit?
I was expecting UnitsNet to already include this functionality and I'm surprised that it doesn't (if it does and I'm missing something, please let me know).
Consider the following:
var size = Information.FromBytes(10000000);
I want to print size
in a human-friendly style. When I do size.ToString()
, I get "1e+07 B"; but what I would ideally want is "10 MB", I want it to detect the most reasonable/closest unit it can display the value with, and use that in the string.
Is this not possible? I would think it's a pretty common thing to need to do.
Hi, there is no support for this. We could offer some basic support I guess to provide a bit more support out of the box, but it would really duplicate some of the efforts that Humanizer already has done. Why not just use Humanizer?
Much of Humanizer's functionality when it comes to units overlaps with UnitsNet's, so using both is a bit awkward, I was hoping UnitsNet would have some basic support in this regard.
If you are interested in attempting a pull request to add this functionality, I'm happy to assist. Let me know.
I don't think it will happen otherwise, I have very limited time to spend on this project.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was automatically closed due to inactivity.