Skip to content

API Overview

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

API Overview

The Energy struct

MarcusMedina.Units.Energy.Energy — a readonly struct implementing IComparable<Energy> and IEquatable<Energy>. Internally stores everything as joules via the Joules property (double).

public Energy(double joules)
public double Joules { get; }

ToString() renders as "{value} J" using invariant culture.

Every creation method below has both an int and a double overload. Factors are the exact multipliers used in source to convert to joules.

MarcusMedina.Units.Energy.Metric

Unit Create Convert back Factor (→ J)
Nanojoule Nanojoules() ToNanojoules() 1e-9
Microjoule Microjoules() ToMicrojoules() 1e-6
Millijoule Millijoules() ToMillijoules() 0.001
Joule Joules() ToJoules() 1
Kilojoule Kilojoules() ToKilojoules() 1,000
Megajoule Megajoules() ToMegajoules() 1,000,000
Gigajoule Gigajoules() ToGigajoules() 1,000,000,000
Terajoule Terajoules() ToTerajoules() 1,000,000,000,000
Watt-hour Watthours() ToWatthours() 3,600
Kilowatt-hour Kilowatthours() ToKilowatthours() 3,600,000
Megawatt-hour Megawatthours() ToMegawatthours() 3,600,000,000
Gigawatt-hour Gigawatthours() ToGigawatthours() 3,600,000,000,000

MarcusMedina.Units.Energy.Scientific

Unit Create Convert back Factor (→ J)
Electronvolt Electronvolts() ToElectronvolts() 1.602176634e-19 (exact, SI 2019)
Kiloelectronvolt Kiloelectronvolts() ToKiloelectronvolts() 1.602176634e-16
Megaelectronvolt Megaelectronvolts() ToMegaelectronvolts() 1.602176634e-13
Gigaelectronvolt Gigaelectronvolts() ToGigaelectronvolts() 1.602176634e-10
Erg (CGS) Ergs() ToErgs() 1e-7
Thermochemical calorie CaloriesThermo() ToCaloriesThermo() 4.184
International Table calorie CaloriesIT() ToCaloriesIT() 4.1868
Kilocalorie Kilocalories() ToKilocalories() 4,184
Ton of TNT TonsOfTNT() ToTonsOfTNT() 4,184,000,000

MarcusMedina.Units.Energy.US

Unit Create Convert back Factor (→ J)
BTU (International Table) BTUs() ToBTUs() 1,055.05585262
Foot-pound force FootPounds() ToFootPounds() 1.3558179483
Foot-poundal FootPoundals() ToFootPoundals() 0.0421401100938
US therm Therms() ToTherms() 105,480,400

Operators (defined on Energy)

Operator Signature Behavior
==, != Energy, Energy Value equality on Joules
<, >, <=, >= Energy, Energy Compares Joules
+ Energy + Energy Adds Joules
- Energy - Energy Subtracts Joules
* Energy * double Scales Joules by a factor
/ Energy / double Divides Joules by a divisor, returns Energy
/ Energy / Energy Divides Joules by Joules, returns double (ratio)

No enums are defined in this package.

Clone this wiki locally