A while ago I read about F#'s Units Of Measure Support. Inspired by this, I just wanted to have some fun and do something like that in C#. The result has come to a point, where I am willing to let it loose to the world.
This is open source. So if someone would like to add something, feel free to make a pull request.
What I have so far
I already implemented metric, imperial and usually some astronomic and/or fun equivalent units of
- Distance
- Area
- Volume
- Mass
- Velocity
- Frequency
- Time
BigDoubles, which are necessary, when converting f.e. between the mass of our sun and gram, are taken from Razenpok - Break Infinity and modified slightly.
The interesting part was, to allow for automatic conversion between units of the same "area", but only those - and to enforce those restrictons already at compile time. I wanted the compiler to tell you, that you can not convert 10 cm to seconds instead of a runtime exception.
Have fun with it and maybe contribute your own favorite fun equivalent: Units Of Measure.
Top comments (0)