Table of Contents

Class Range<TValue>

Namespace
Bonsai
Assembly
Bonsai.Core.dll

Represents a range of values defined by an inclusive lower and upper bounds.

public sealed class Range<TValue> : IEquatable<Range<TValue>>

Type Parameters

TValue

The type of values in the range.

Inheritance
Range<TValue>
Implements
IEquatable<Range<TValue>>
Inherited Members

Constructors

Range(TValue, TValue)

Initializes a new instance of the Range<TValue> class with the specified lower and upper bounds.

public Range(TValue lowerBound, TValue upperBound)

Parameters

lowerBound TValue

The inclusive lower bound of the range.

upperBound TValue

The inclusive upper bound of the range.

Range(TValue, TValue, IComparer<TValue>)

Initializes a new instance of the Range<TValue> class with the specified lower and upper bounds and using the specified comparer.

public Range(TValue lowerBound, TValue upperBound, IComparer<TValue> comparer)

Parameters

lowerBound TValue

The inclusive lower bound of the range.

upperBound TValue

The inclusive upper bound of the range.

comparer IComparer<TValue>

An IComparer<T> to use to compare values.

Properties

LowerBound

Gets the inclusive lower bound of the range.

public TValue LowerBound { get; }

Property Value

TValue

UpperBound

Gets the inclusive upper bound of the range.

public TValue UpperBound { get; }

Property Value

TValue

Methods

Contains(TValue)

Tests whether a specified value falls within the range.

public bool Contains(TValue value)

Parameters

value TValue

The value to test.

Returns

bool

true if value is between or equal to the lower and upper bound values of this instance; otherwise, false.

Equals(Range<TValue>)

Returns a value indicating whether this instance has the same lower and upper bounds as a specified Range<TValue> object.

public bool Equals(Range<TValue> other)

Parameters

other Range<TValue>

The Range<TValue> object to compare to this instance.

Returns

bool

true if other has the same lower and upper bounds as this instance; otherwise, false.

Equals(object)

Tests to see whether the specified object is a Range<TValue> object with the same lower and upper bounds as this Range<TValue> instance.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

true if obj is a Range<TValue> and has the same lower and upper bounds as this Range<TValue>; otherwise, false.

GetHashCode()

Returns a hash code for the current instance.

public override int GetHashCode()

Returns

int

The hash code for the current instance.

ToString()

Creates a string representation of this Range<TValue>.

public override string ToString()

Returns

string

A string containing the lower and upper bound values of this Range<TValue>.

Operators

operator ==(Range<TValue>, Range<TValue>)

Tests whether two Range<TValue> objects are equal.

public static bool operator ==(Range<TValue> left, Range<TValue> right)

Parameters

left Range<TValue>

The Range<TValue> object on the left-hand side of the equality operator.

right Range<TValue>

The Range<TValue> object on the right-hand side of the equality operator.

Returns

bool

true if left and right have equal lower and upper bounds; otherwise, false.

operator !=(Range<TValue>, Range<TValue>)

Tests whether two Range<TValue> objects are different.

public static bool operator !=(Range<TValue> left, Range<TValue> right)

Parameters

left Range<TValue>

The Range<TValue> object on the left-hand side of the inequality operator.

right Range<TValue>

The Range<TValue> object on the right-hand side of the inequality operator.

Returns

bool

true if left and right differ either in their lower or upper bounds; false if left and right are equal.