Repository navigation
API Overview
Every unit below exposes two extension methods: a creation method on int/double (e.g. Kilograms()) and a conversion method on Weight (e.g. ToKilograms()). Weight always stores its value internally in grams, so any unit can be freely mixed with any other.
MarcusMedina.Units.Weight.Weight — readonly struct, base unit grams (Grams property). Implements IComparable<Weight>, IEquatable<Weight>, and operators +, -, * (by double), / (by double or by another Weight), plus ==, !=, <, >, <=, >=.
SI-standard units, grams as base.
| Unit | Create | Convert |
|---|---|---|
| Nanogram | Nanograms() |
ToNanograms() |
| Microgram | Micrograms() |
ToMicrograms() |
| Milligram | Milligrams() |
ToMilligrams() |
| Centigram | Centigrams() |
ToCentigrams() |
| Decigram | Decigrams() |
ToDecigrams() |
| Gram | Grams() |
ToGrams() |
| Decagram | Decagrams() |
ToDecagrams() |
| Hectogram | Hectograms() |
ToHectograms() |
| Kilogram | Kilograms() |
ToKilograms() |
| Tonne | Tonnes() |
ToTonnes() |
US customary units. Pound and ounce match British imperial; short ton is US-specific (2000 lb, vs. the British long ton's 2240 lb).
| Unit | Create | Convert |
|---|---|---|
| Grain (0.06479891 g) | Grains() |
ToGrains() |
| Dram (1.7718452 g) | Drams() |
ToDrams() |
| Ounce (28.349523125 g) | Ounces() |
ToOunces() |
| Pound (453.59237 g) | Pounds() |
ToPounds() |
| Short hundredweight (100 lb) | ShortHundredweights() |
ToShortHundredweights() |
| Short ton (2000 lb) | ShortTons() |
ToShortTons() |
Modern British imperial units.
| Unit | Create | Convert |
|---|---|---|
| Grain (0.06479891 g) | Grains() |
ToGrains() |
| Drachm (1/16 oz) | Drachms() |
ToDrachms() |
| Ounce (28.349523125 g) | Ounces() |
ToOunces() |
| Pound (453.59237 g) | Pounds() |
ToPounds() |
| Stone (14 lb) | Stone() |
ToStone() |
| Quarter (2 stone) | Quarters() |
ToQuarters() |
| Hundredweight (8 stone / long) | Hundredweights() |
ToHundredweights() |
| Long ton (2240 lb) | LongTons() |
ToLongTons() |
Historical Troy and Apothecary systems.
| Unit | Create | Convert |
|---|---|---|
| Troy grain (0.06479891 g, same as imperial grain) | TroyGrains() |
ToTroyGrains() |
| Pennyweight (24 Troy grains) | Pennyweights() |
ToPennyweights() |
| Troy ounce (20 pennyweights) | TroyOunces() |
ToTroyOunces() |
| Troy pound (12 Troy ounces) | TroyPounds() |
ToTroyPounds() |
| Scruple (20 grains) | Scruples() |
ToScruples() |
| Apothecary dram (3 scruples) | ApothecaryDrams() |
ToApothecaryDrams() |
| Apothecary ounce (8 apothecary drams) | ApothecaryOunces() |
ToApothecaryOunces() |
Historical Swedish "viktlod" system, in use before 1889.
| Unit | Create | Convert |
|---|---|---|
| Ort (≈0.2102 g) | Ort() |
ToOrt() |
| Kvintin (1/32 lod) | Kvintin() |
ToKvintin() |
| Lod (1/32 skålpund) | Lod() |
ToLod() |
| Skålpund (425.076 g) | Skålpund() |
ToSkålpund() |
| Lispund (20 skålpund) | Lispund() |
ToLispund() |
| Centner (100 skålpund) | Centner() |
ToCentner() |
| Skeppspund (20 lispund / 400 skålpund) | Skeppspund() |
ToSkeppspund() |