Search code examples
c#f#units-of-measurement

Cooking Measurements in C# / F#


Do any of you know a library for the representation and calculation of cooking units (Cup, Tablespoon, Gallon...) in C# or F# (especially in regard to culture, metric/imperial)?


Solution

  • Units of measure are built into the F# language:

    http://msdn.microsoft.com/en-us/library/dd233243.aspx

    They can be easily extended with custom units, as long as you know conversion ratios.

    Edit: Of course, you might end up with some strange unit types to account between differences in weights and volumes (the ratio of 1 cup of flour to 1 cup of water is not the same as the ratio of 100g of flour to 100g of water...)