Click or drag to resize

Distance Structure

Defines a distance in terms of its numeric value and its unit of measurement (e.g. 20 miles).
Inheritance Hierarchy
SystemObject
  SystemValueType
    DegreeDays.GeoDistance

Namespace: DegreeDays.Geo
Assembly: DegreeDays (in DegreeDays.dll) Version: 1.4
Syntax
public struct Distance : IEquatable<Distance>

The Distance type exposes the following members.

Constructors
 NameDescription
Public methodDistance Constructs a new Distance with the specified value and unit of measurement.
Top
Properties
 NameDescription
Public propertyUnit Gets the unit of measurement of this Distance.
Public propertyValue Gets the numeric value of this Distance.
Top
Methods
 NameDescription
Public methodEquals(Distance) Returns true if other has an equal unit and an equal value.
Public methodEquals(Object) Returns true if obj is a Distance with an equal unit and an equal value.
(Overrides ValueTypeEquals(Object))
Public methodStatic memberFeet Returns a Distance with the specified value and Feet as the unit of measurement.
Public methodGetHashCode Overridden to ensure consistency with Equals.
(Overrides ValueTypeGetHashCode)
Public methodIn Returns a Distance that represents this Distance converted into the specified unit of measurement.
Public methodInFeet Returns a Distance that represents this Distance converted into feet.
Public methodInKilometres Returns a Distance that represents this Distance converted into kilometres.
Public methodInMetres Returns a Distance that represents this Distance converted into metres.
Public methodInMiles Returns a Distance that represents this Distance converted into miles.
Public methodInt32Value Returns the distance value, rounded to the nearest integer.
Public methodStatic memberKilometres Returns a Distance with the specified value and Kilometres as the unit of measurement.
Public methodStatic memberMetres Returns a Distance with the specified value and Metres as the unit of measurement.
Public methodStatic memberMiles Returns a Distance with the specified value and Miles as the unit of measurement.
Public methodToString Returns a non-null, non-empty string representation of this instance for logging and debugging purposes.
(Overrides ValueTypeToString)
Top
Operators
 NameDescription
Public operatorStatic memberEquality(Distance, Distance) Determines whether two specified Distance instances are equal.
Public operatorStatic memberInequality(Distance, Distance) Determines whether two specified Distance instances are not equal.
Top
Remarks

To create a Distance, it's usually easiest to use the static factory methods: Metres(Double), Kilometres(Double), Feet(Double) and Miles(Double). For example:

Distance twentyMiles = Distance.Miles(20);

It's easy to convert between units:

Distance twentyMilesInMetres = twentyMiles.InMetres();
Thread Safety
Instances of this struct are immutable and safe for use from multiple threads at once.
See Also