Skip to content

API Overview

Marcus Ackre Medina edited this page Sep 13, 2026 · 1 revision

API Reference

Every unit below exposes two extension methods: a creation method (int/double → Volume) and a conversion method (Volume → double), e.g. Liters() / ToLiters(). The underlying Volume struct always stores its value in millilitres.

Volume struct (MarcusMedina.Units.Volume)

Member Description
Milliliters The value in millilitres — the struct's base unit.
CompareTo, Equals, GetHashCode, ToString Standard comparison/equality/formatting; ToString() renders as "<value> mL".
==, !=, <, >, <=, >= Full comparison operator set.
+, - Add/subtract two Volume values.
* double, / double Scale a Volume by a scalar.
/ Volume Divide two Volume values to get a dimensionless ratio (double).

Metric (MarcusMedina.Units.Volume.Metric)

Method Description
Nanoliters() / ToNanoliters() nL
Microliters() / ToMicroliters() µL
Milliliters() / ToMilliliters() mL (base unit)
CubicMillimeters() / ToCubicMillimeters() mm³
CubicCentimeters() / ToCubicCentimeters() cm³ (equal to mL)
Centiliters() / ToCentiliters() cL
Deciliters() / ToDeciliters() dL
Liters() / ToLiters() L
Decaliters() / ToDecaliters() daL
Hectoliters() / ToHectoliters() hL
Kiloliters() / ToKiloliters() kL
CubicMeters() / ToCubicMeters() m³

US customary (MarcusMedina.Units.Volume.US)

Method Description
TeaspoonUS() / ToTeaspoonUS() US teaspoon — 4.92892 mL
TablespoonUS() / ToTablespoonUS() US tablespoon — 14.78676 mL
FluidOunceUS() / ToFluidOunceUS() US fluid ounce — 29.57353 mL
CupUS() / ToCupUS() US cup — 236.5882 mL
PintUS() / ToPintUS() US pint — 473.1765 mL
QuartUS() / ToQuartUS() US quart — 946.3529 mL
GallonUS() / ToGallonUS() US gallon — 3 785.412 mL

British imperial (MarcusMedina.Units.Volume.British)

Deliberately separate from the US units above — a UK gallon is ≈ 4.546 L, not ≈ 3.785 L.

Method Description
TeaspoonUK() / ToTeaspoonUK() UK teaspoon — 5.91939 mL
TablespoonUK() / ToTablespoonUK() UK tablespoon — 17.7582 mL
FluidOunceUK() / ToFluidOunceUK() UK fluid ounce — 28.4131 mL
GillUK() / ToGillUK() UK gill — 142.065 mL
PintUK() / ToPintUK() UK pint — 568.261 mL
QuartUK() / ToQuartUK() UK quart — 1 136.52 mL
GallonUK() / ToGallonUK() UK gallon — 4 546.09 mL

Historical Swedish (MarcusMedina.Units.Volume.SwedishOld)

Units used in Sweden before the metric system (pre-1889). Kanna was the main reference unit.

Method Description
Jungfru() / ToJungfru() 1/4 stop — 81.93 mL
Stop() / ToStop() 1/8 kanna — 327.72 mL
Kanna() / ToKanna() Main unit — 2 617.7 mL (= 2.6177 L)
Ankare() / ToAnkare() 15 kannor — 39 265.5 mL (beer cask)
Tunna() / ToTunna() 48 kannor — 125 649.6 mL (dry volume for grain)

All method overloads accept both int and double inputs (e.g. 5.Liters() and 5.0.Liters() both work).