NumericRange

Ecng.ComponentModel

Represents a numeric range for supporting generic math operations.

実装: IRange<T>, IRange, ICloneable

コンストラクター

NumericRange
public NumericRange(TNumber min, TNumber max)
numericRange = NumericRange(min, max)

Initializes a new instance of the NumericRange struct.

min
The lower bound of the range (inclusive).
max
The upper bound of the range (inclusive).

プロパティ

Length
public TNumber Length { get; }
value = numericRange.Length

Gets the range length computed as Max minus Min.

Max
public TNumber Max { get; }
value = numericRange.Max

Gets the upper bound of the range (inclusive).

Min
public TNumber Min { get; }
value = numericRange.Min

Gets the lower bound of the range (inclusive).

メソッド

Contains
public bool Contains(TNumber value)
result = numericRange.Contains(value)

Determines whether the specified value is contained in the current range (inclusive).

value
The value to test.

戻り値: true if lies in [Min, Max]; otherwise false.

Contains
public bool Contains(NumericRange<TNumber> other)
result = numericRange.Contains(other)

Determines whether the specified range is completely contained in the current range.

other
The range to test.

戻り値: true if is inside this range; otherwise false.

Intersect
public NumericRange<TNumber>? Intersect(NumericRange<TNumber> other)
result = numericRange.Intersect(other)

Computes the intersection between the current range and .

other
The range to intersect with.

戻り値: A new NumericRange describing the overlap, or null when the ranges do not intersect.

SubRange
public NumericRange<TNumber> SubRange(TNumber min, TNumber max)
result = numericRange.SubRange(min, max)

Creates a sub-range from the current range with the specified bounds.

min
The minimum bound of the sub-range.
max
The maximum bound of the sub-range.

戻り値: The sub-range within the current range.

ToString
public override string ToString()
result = numericRange.ToString()

Returns a string that represents the current range using the format "{Min: X Max: Y}".

戻り値: A string representation of the range.