Struct LengthUnit
Encapsulates a length, stored internally in meters, and provides properties that allow for conversions and interactions between multiple metric, imperial, and astronomical distance units.
Implements
Inherited Members
Namespace: Scylla.Core.Util.Units
Assembly: ScyllaCore.dll
Syntax
public struct LengthUnit : IEquatable<LengthUnit>
Remarks
LengthUnit uses double precision throughout. The internal
representation is meters, with all conversions routed through a centimeter
intermediate to maintain a single consistent arithmetic path.
Unlike DataUnit, LengthUnit supports negative
values, making it suitable for signed offsets and direction-aware distances.
All property setters validate that the assigned value is finite (not NaN or
infinite) via NumberUtil.EnsureFinite.
Three groups of units are supported:
- Metric (SI): Planck length through petameters, plus angstrom.
- Imperial / US customary: thou, inch, foot, yard, rod, fathom, chain, furlong, mile, survey mile, league, nautical mile, cable.
- Astronomical: astronomical unit (AU), light-second, light-minute, light-hour, light-day, light-year (Julian), parsec, kiloparsec, megaparsec, gigaparsec.
All astronomical constants use deterministic, fixed values: the IAU definition of AU (149,597,870,700 m), the exact speed of light (299,792,458 m/s), and a Julian year of 365.25 days (31,557,600 seconds).
Equality uses NumberUtil.Approximately; ordering operators use exact
meter-level comparison.
ToString() automatically selects the most human-readable unit from the full range (Planck length through gigaparsec), preferring astronomical scales over SI metric prefixes at overlapping magnitudes.
var d = new LengthUnit();
d.Kilometer = 1.5;
Console.WriteLine(d.Mile); // ~0.932
Console.WriteLine(d.LightSecond); // ~5e-6
Console.WriteLine(d); // "1.5 km"
var a = new LengthUnit { Meter = 100 };
var b = new LengthUnit { Foot = 100 };
var diff = a - b; // 100 m - 30.48 m
Constructors
LengthUnit(double)
Initializes a new LengthUnit instance with the given length in meters.
Declaration
public LengthUnit(double meters = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| double | meters | The initial length in meters. May be negative (for signed offsets). Must be
finite (not NaN or infinite). Defaults to |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown if |
Properties
Angstrom
Gets or sets the length expressed in angstroms (Å), where 1 Å = 10^-10 m. The angstrom is a non-SI unit widely used in chemistry and crystallography to express interatomic distances and wavelengths of visible light (~4000-7000 Å).
Declaration
public double Angstrom { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
AstronomicalUnit
Gets or sets the length expressed in astronomical units (AU), using the exact IAU 2012 definition where 1 AU = 149,597,870,700 m. One AU is the mean distance from the Earth to the Sun and is the standard reference scale for the solar system.
Declaration
public double AstronomicalUnit { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Attometer
Gets or sets the length expressed in attometers (am), where 1 am = 10^-18 m. This scale is relevant for nuclear physics (proton radius ~0.85 fm = 850 am).
Declaration
public double Attometer { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Cable
Gets or sets the length expressed in cables, where 1 cable = 0.1 nmi = 185.2 m. The cable is a traditional nautical unit used to express short distances at sea.
Declaration
public double Cable { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Centimeter
Gets or sets the length expressed in centimeters (cm), where 1 cm = 0.01 m. Centimeters are the intermediate unit used internally for all conversion arithmetic within this struct.
Declaration
public double Centimeter { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Chain
Gets or sets the length expressed in chains (Gunter's chain), where 1 chain = 66 ft = 20.1168 m. The chain is the traditional unit for UK land registration and surveying; a cricket pitch is exactly 1 chain long.
Declaration
public double Chain { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Decameter
Gets or sets the length expressed in decameters (dam), where 1 dam = 10 m. Decameters are rarely used in practice but are included for completeness of the SI prefix ladder.
Declaration
public double Decameter { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Fathom
Gets or sets the length expressed in fathoms, where 1 fathom = 6 ft = 1.8288 m. The fathom is a traditional nautical depth measurement unit.
Declaration
public double Fathom { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Femtometer
Gets or sets the length expressed in femtometers (fm), also called fermi, where 1 fm = 10^-15 m. The femtometer is the characteristic scale of atomic nuclei (proton radius ~0.85 fm).
Declaration
public double Femtometer { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Foot
Gets or sets the length expressed in feet (ft), where 1 ft = 12 inches = 30.48 cm. Uses the international foot definition.
Declaration
public double Foot { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Furlong
Gets or sets the length expressed in furlongs, where 1 furlong = 660 ft = 201.168 m. Eight furlongs make one statute mile. Furlongs remain in use in horse racing.
Declaration
public double Furlong { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Gigameter
Gets or sets the length expressed in gigameters (Gm), where 1 Gm = 10^9 m. The Earth-Moon average distance is approximately 0.384 Gm.
Declaration
public double Gigameter { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Gigaparsec
Gets or sets the length expressed in gigaparsecs (Gpc), where 1 Gpc = 10^9 pc. Gigaparsecs are used for the largest observable cosmological scales; the observable universe has a radius of approximately 14.26 Gpc.
Declaration
public double Gigaparsec { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Hectometer
Gets or sets the length expressed in hectometers (hm), where 1 hm = 100 m.
Declaration
public double Hectometer { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Inch
Gets or sets the length expressed in inches (in), using the exact international definition where 1 in = 2.54 cm.
Declaration
public double Inch { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Kilometer
Gets or sets the length expressed in kilometers (km), where 1 km = 1000 m. Kilometers are the standard unit for road distances in most countries.
Declaration
public double Kilometer { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Kiloparsec
Gets or sets the length expressed in kiloparsecs (kpc), where 1 kpc = 1000 pc. Kiloparsecs are used for intragalactic distances; the Milky Way disc is roughly 30 kpc in diameter.
Declaration
public double Kiloparsec { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
League
Gets or sets the length expressed in leagues, where 1 league = 3 statute miles = 4828.032 m. The league is a historical unit representing roughly one hour of walking.
Declaration
public double League { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
LightDay
Gets or sets the length expressed in light-days - the distance light travels in one day (86,400 seconds). Pluto is roughly 0.00053 light-days from the Sun at mean distance.
Declaration
public double LightDay { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
LightHour
Gets or sets the length expressed in light-hours - the distance light travels in one hour. Equal to 3600 light-seconds. The Sun is approximately 0.0022 light-hours from Earth.
Declaration
public double LightHour { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
LightMinute
Gets or sets the length expressed in light-minutes - the distance light travels in one minute. Equal to 60 light-seconds, or 17,987,547,480 m.
Declaration
public double LightMinute { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
LightSecond
Gets or sets the length expressed in light-seconds - the distance light travels in one second in a vacuum. Uses the exact speed of light c = 299,792,458 m/s, so 1 light-second = 299,792,458 m.
Declaration
public double LightSecond { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
LightYear
Gets or sets the length expressed in light-years - the distance light travels in one Julian year (365.25 days = 31,557,600 seconds). Using a deterministic Julian year rather than a tropical or Gregorian year ensures a fixed, reproducible conversion factor. One light-year is approximately 9.4607 × 10^15 m.
Declaration
public double LightYear { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Megameter
Gets or sets the length expressed in megameters (Mm), where 1 Mm = 10^6 m. Earth's radius is approximately 6.371 Mm.
Declaration
public double Megameter { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Megaparsec
Gets or sets the length expressed in megaparsecs (Mpc), where 1 Mpc = 10^6 pc. Megaparsecs are the standard unit for intergalactic and large-scale cosmological distances; the Andromeda Galaxy is approximately 0.78 Mpc from the Milky Way.
Declaration
public double Megaparsec { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Meter
Gets or sets the length expressed in meters (m), the SI base unit of length and the canonical internal storage unit of LengthUnit. Reading this property returns the raw stored value without conversion.
Declaration
public double Meter { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Micrometer
Gets or sets the length expressed in micrometers (µm), also commonly called microns, where 1 µm = 10^-6 m. Micrometers describe biological cell sizes, fine dust particles, and precision machining tolerances.
Declaration
public double Micrometer { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Mile
Gets or sets the length expressed in statute miles (mi), where 1 mi = 5280 ft = 1609.344 m. Uses the international (not US survey) mile definition. For the survey mile variant, see SurveyMile.
Declaration
public double Mile { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Millimeter
Gets or sets the length expressed in millimeters (mm), where 1 mm = 0.001 m.
Declaration
public double Millimeter { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Nanometer
Gets or sets the length expressed in nanometers (nm), where 1 nm = 10^-9 m. Nanometers are commonly used in optics (visible light wavelengths: ~380-700 nm) and semiconductor manufacturing (transistor node sizes).
Declaration
public double Nanometer { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
NauticalMile
Gets or sets the length expressed in nautical miles (nmi), using the exact international definition where 1 nmi = 1852 m. The nautical mile is defined as one minute of arc along a meridian of the Earth and is the standard unit for maritime and aviation navigation.
Declaration
public double NauticalMile { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Parsec
Gets or sets the length expressed in parsecs (pc). One parsec is the distance at which one AU subtends one arcsecond, equal to approximately 3.0857 × 10^16 m (~3.262 light-years). The IAU-style constant is used for the conversion factor.
Declaration
public double Parsec { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Petameter
Gets or sets the length expressed in petameters (Pm), where 1 Pm = 10^15 m. One light-year is approximately 9.461 Pm.
Declaration
public double Petameter { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Picometer
Gets or sets the length expressed in picometers (pm), where 1 pm = 10^-12 m. The picometer is a common scale for atomic bond lengths and crystal lattice spacings.
Declaration
public double Picometer { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
PlanckLength
Gets or sets the length expressed in Planck lengths, the smallest meaningful
length scale in physics. The Planck length constant used is the CODATA-recommended
value of approximately 1.616255 × 10^-35 m.
This property is provided for completeness; at this scale, double precision
cannot distinguish individual Planck lengths from zero.
Declaration
public double PlanckLength { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Rod
Gets or sets the length expressed in rods (also called poles or perches), where 1 rod = 16.5 ft = 5.0292 m. Rods are used in historical surveying and some agricultural land measurements.
Declaration
public double Rod { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
SurveyMile
Gets or sets the length expressed in US survey miles, where 1 survey mile = 5280 survey feet. The US survey foot is defined as exactly 1200/3937 meters, making the survey mile approximately 1609.347 m - about 3.2 mm longer than the international mile (Mile). Used in US land surveys and legal descriptions.
Declaration
public double SurveyMile { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Terameter
Gets or sets the length expressed in terameters (Tm), where 1 Tm = 10^12 m. The Earth-Sun average distance (1 AU) is approximately 0.15 Tm.
Declaration
public double Terameter { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Thou
Gets or sets the length expressed in thou (also called mil), where 1 thou = 0.001 in = 0.0254 mm. Thou are used in precision engineering and PCB trace width specifications.
Declaration
public double Thou { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Yard
Gets or sets the length expressed in yards (yd), where 1 yd = 3 ft = 91.44 cm.
Declaration
public double Yard { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Yoctometer
Gets or sets the length expressed in yoctometers (ym), the smallest named SI metric prefix, where 1 ym = 10^-24 m.
Declaration
public double Yoctometer { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Zeptometer
Gets or sets the length expressed in zeptometers (zm), where 1 zm = 10^-21 m.
Declaration
public double Zeptometer { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown by the setter if the assigned value is NaN or infinite. |
Methods
Equals(LengthUnit)
Determines whether the specified LengthUnit is equal to this instance.
Uses NumberUtil.Approximately on the raw meter counts to tolerate
floating-point rounding from repeated unit conversions.
Declaration
public bool Equals(LengthUnit other)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | other | The LengthUnit to compare with this instance. |
Returns
| Type | Description |
|---|---|
| bool | true if |
Equals(object)
Determines whether the specified object is equal to this LengthUnit
instance. Only returns true when obj is
itself a LengthUnit with an approximately equal meter count.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with this instance. May be null. |
Returns
| Type | Description |
|---|---|
| bool | true if |
Overrides
GetHashCode()
Returns a hash code derived from the raw meter count of this instance, suitable for use in hash tables and dictionaries.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A 32-bit integer hash code based on the internal |
Overrides
ToString()
Returns a human-readable string that expresses the stored length in the most appropriate unit for the current magnitude, spanning the full range from Planck lengths to gigaparsecs.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A formatted string such as
The sign of negative values is preserved (e.g., Selection logic prefers astronomical units at scales where both SI metric and astronomical names are applicable (e.g., a gigaparsec is chosen over ~30 petameters). The fallback at sub-yoctometer scale is Planck lengths. Numeric formatting uses two decimal places for values below 10, one decimal place for values below 100, and zero decimal places otherwise. Trailing zeros and redundant decimal points are trimmed. |
Overrides
Operators
operator +(LengthUnit, LengthUnit)
Adds two LengthUnit values together, combining their meter counts.
Declaration
public static LengthUnit operator +(LengthUnit left, LengthUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The first operand. |
| LengthUnit | right | The second operand. |
Returns
| Type | Description |
|---|---|
| LengthUnit | A new LengthUnit whose meter count equals the sum of
|
operator /(LengthUnit, LengthUnit)
Divides one LengthUnit by another, returning the dimensionless ratio
of their meter counts as a double. Useful for computing scale factors between
two lengths.
Declaration
public static double operator /(LengthUnit left, LengthUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The dividend. |
| LengthUnit | right | The divisor. Must represent a non-zero meter count. |
Returns
| Type | Description |
|---|---|
| double | The ratio |
Exceptions
| Type | Condition |
|---|---|
| DivideByZeroException | Thrown when |
operator /(LengthUnit, double)
Divides a LengthUnit by a double-precision floating-point scalar, producing a proportionally smaller or larger length depending on the scalar.
Declaration
public static LengthUnit operator /(LengthUnit left, double right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The LengthUnit dividend. |
| double | right | The scalar divisor. Must be finite and non-zero. |
Returns
| Type | Description |
|---|---|
| LengthUnit | A new LengthUnit whose meter count equals
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
| DivideByZeroException | Thrown when |
operator /(LengthUnit, int)
Divides a LengthUnit by an integer scalar.
Declaration
public static LengthUnit operator /(LengthUnit left, int right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The LengthUnit dividend. |
| int | right | The integer scalar divisor. Must not be zero. |
Returns
| Type | Description |
|---|---|
| LengthUnit | A new LengthUnit whose meter count equals
|
Exceptions
| Type | Condition |
|---|---|
| DivideByZeroException | Thrown when |
operator ==(LengthUnit, LengthUnit)
Determines whether two LengthUnit values represent the same length.
Uses NumberUtil.Approximately to tolerate floating-point rounding from
unit conversions.
Declaration
public static bool operator ==(LengthUnit left, LengthUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The left operand. |
| LengthUnit | right | The right operand. |
Returns
| Type | Description |
|---|---|
| bool | true if the meter counts of |
operator >(LengthUnit, LengthUnit)
Determines whether one LengthUnit is strictly longer than another. Uses exact meter-level comparison (not approximate equality).
Declaration
public static bool operator >(LengthUnit left, LengthUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The left operand. |
| LengthUnit | right | The right operand. |
Returns
| Type | Description |
|---|---|
| bool |
operator >=(LengthUnit, LengthUnit)
Determines whether one LengthUnit is longer than or equal in length to another. Uses exact meter-level comparison.
Declaration
public static bool operator >=(LengthUnit left, LengthUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The left operand. |
| LengthUnit | right | The right operand. |
Returns
| Type | Description |
|---|---|
| bool | true if |
operator !=(LengthUnit, LengthUnit)
Determines whether two LengthUnit values represent different lengths.
Uses NumberUtil.Approximately for comparison, mirroring the == operator.
Declaration
public static bool operator !=(LengthUnit left, LengthUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The left operand. |
| LengthUnit | right | The right operand. |
Returns
| Type | Description |
|---|---|
| bool | true if the meter counts of |
operator <(LengthUnit, LengthUnit)
Determines whether one LengthUnit is strictly shorter than another. Uses exact meter-level comparison (not approximate equality).
Declaration
public static bool operator <(LengthUnit left, LengthUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The left operand. |
| LengthUnit | right | The right operand. |
Returns
| Type | Description |
|---|---|
| bool |
operator <=(LengthUnit, LengthUnit)
Determines whether one LengthUnit is shorter than or equal in length to another. Uses exact meter-level comparison.
Declaration
public static bool operator <=(LengthUnit left, LengthUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The left operand. |
| LengthUnit | right | The right operand. |
Returns
| Type | Description |
|---|---|
| bool | true if |
operator *(LengthUnit, double)
Multiplies a LengthUnit by a double-precision floating-point scalar, scaling the stored meter count proportionally.
Declaration
public static LengthUnit operator *(LengthUnit left, double right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The LengthUnit operand. |
| double | right | The scalar multiplier. Must be finite (not NaN or infinite). |
Returns
| Type | Description |
|---|---|
| LengthUnit | A new LengthUnit whose meter count equals
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
operator *(LengthUnit, int)
Multiplies a LengthUnit by an integer scalar, scaling the stored meter count by an exact whole-number factor.
Declaration
public static LengthUnit operator *(LengthUnit left, int right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The LengthUnit operand. |
| int | right | The integer scalar multiplier. |
Returns
| Type | Description |
|---|---|
| LengthUnit | A new LengthUnit whose meter count equals
|
operator *(double, LengthUnit)
Multiplies a double-precision floating-point scalar by a LengthUnit,
scaling the stored meter count proportionally. Allows scalar-first syntax such as
2.5 * someLength.
Declaration
public static LengthUnit operator *(double left, LengthUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| double | left | The scalar multiplier. Must be finite (not NaN or infinite). |
| LengthUnit | right | The LengthUnit operand. |
Returns
| Type | Description |
|---|---|
| LengthUnit | A new LengthUnit whose meter count equals
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
operator *(int, LengthUnit)
Multiplies an integer scalar by a LengthUnit, scaling the stored
meter count by an exact whole-number factor. Allows integer-first syntax such as
3 * someLength.
Declaration
public static LengthUnit operator *(int left, LengthUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| int | left | The integer scalar multiplier. |
| LengthUnit | right | The LengthUnit operand. |
Returns
| Type | Description |
|---|---|
| LengthUnit | A new LengthUnit whose meter count equals
|
operator -(LengthUnit, LengthUnit)
Subtracts one LengthUnit value from another. Because LengthUnit supports negative values, the result may be negative.
Declaration
public static LengthUnit operator -(LengthUnit left, LengthUnit right)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | left | The minuend (the value to subtract from). |
| LengthUnit | right | The subtrahend (the value to subtract). |
Returns
| Type | Description |
|---|---|
| LengthUnit | A new LengthUnit whose meter count equals
|
operator -(LengthUnit)
Negates a LengthUnit value, reversing its sign. Useful for expressing an offset in the opposite direction.
Declaration
public static LengthUnit operator -(LengthUnit value)
Parameters
| Type | Name | Description |
|---|---|---|
| LengthUnit | value | The operand to negate. |
Returns
| Type | Description |
|---|---|
| LengthUnit | A new LengthUnit whose meter count equals
|