Struct Diameter
A non-negative scalar wrapper over UnitsNet.Length representing a circle's diameter.
A Diameter is the full width of a circle: exactly twice the Radius. Like Radius, it enforces the non-negative constraint at construction time.
It implicitly converts to UnitsNet.Length for compatibility with APIs that accept raw lengths, and can be converted to a Radius via the Radius property.
public readonly record struct Diameter : IEquatable<Diameter>
- Implements
- Inherited Members
Examples
var d = new Diameter(Length.FromMeters(10));
Radius r = d.Radius; // 5 m
Length l = d; // 10 m (implicit conversion)
Constructors
Diameter(Length)
Initialises a Diameter with the given length.
public Diameter(Length value)
Parameters
valueLengthThe diameter length. Must be zero or positive.
Exceptions
- ArgumentException
Thrown when
valueis negative.
Properties
Radius
Returns the corresponding Radius (half this diameter).
public Radius Radius { get; }
Property Value
Value
The diameter length.
public Length Value { get; }
Property Value
- Length
Zero
A Diameter of zero.
public static Diameter Zero { get; }
Property Value
Methods
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
implicit operator Length(Diameter)
Allows a Diameter to be used wherever a UnitsNet.Length is expected.
public static implicit operator Length(Diameter diameter)
Parameters
diameterDiameter
Returns
- Length
operator *(double, Diameter)
Scales a diameter by a dimensionless factor. Operands may be supplied in either order.
public static Diameter operator *(double scalar, Diameter diameter)
Parameters
Returns
operator *(Diameter, double)
Scales this diameter by a dimensionless factor.
public static Diameter operator *(Diameter diameter, double scalar)
Parameters
diameterDiameterThe diameter to scale.
scalardoubleThe scaling factor. Must be non-negative to keep the result valid.