Question

Has C#/the .NET library builtin routines or constants for converting e. g. millimetres to inches? If so, where can I find them? (I just do not want to produce duplicate code again and again.)

Was it helpful?

Solution

No, there are no such build in routines or constants in the framework.

OTHER TIPS

Totally gratuiitous off topic reply

F# has built in support for units. This is a random blog I just Binged Units Of Measure In F#

Here's a CodeProject sample that does unit conversion:

http://www.codeproject.com/KB/cs/Thunder.aspx

It's not built-in to .Net, but it will save you from having to write all this stuff yourself.

Update: it makes a bit of sense that this would not be part of .Net, because there are issues regarding the degree of precision to use in the conversions and the constants which are probably best left to the developer.

just roll your own set of assemblies which contain the functions so that you don't have to duplicate the code. a simple google search will yield the common conversion formulas. here's a good page.

edited to add the second link...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top