Range Struct
Represents an ordered pair of min and max values.
public struct Range
Constructors
Range(int)
Initializes a new instance of the Range class with the specified min and max value.
public Range(int value)
Parameter | Type | Description |
---|---|---|
value | int | The value to use for both the min and max. |
Range(int, int)
Initializes a new instance of the Range class with the specified min and max values.
public Range(int min, int max)
Parameter | Type | Description |
---|---|---|
min | int | The minimum value of the range. |
max | int | The maximum value of the range. |
Properties
Empty
Returns an empty Range.
IsEmpty
Returns whether the Range is empty.
IsNormalized
Gets whether the range is normalized (the maximum value is greater than or equal to the minimum).
public bool IsNormalized { get; }
Property Value
- bool:
true
if the range is normalized; otherwise,false
.
IsZeroLength
Gets whether the range has a zero length.
public bool IsZeroLength { get; }
Property Value
- bool:
true
if the range has a zero length; otherwise,false
.
Length
Gets the length of this Range.
Max
Gets or sets the maximum value of this Range.
Min
Gets or sets the minimum value of this Range.
Methods
Contains(Range)
Returns whether the range inclusively contains the specified Range.
public bool Contains(Range range)
Parameter | Type | Description |
---|---|---|
range | Range | The Range to check. |
Returns
Contains(int)
Returns whether the range inclusively contains the specified value.
public bool Contains(int value)
Parameter | Type | Description |
---|---|---|
value | int | The value to check. |
Returns
- bool:
true
if the range inclusively contains the specified value; otherwise,false
.
Equals(object)
Determines whether the specified Object
is equal to the current Object
.
public override bool Equals(object obj)
Parameter | Type | Description |
---|---|---|
obj | object | The |
Returns
- bool:
true
if the specifiedObject
is equal to the currentObject
; otherwise,false
.
GetHashCode()
Returns a hash code for this object.
public override int GetHashCode()
Returns
- int:
An integer value that specifies a hash value for this object.
Intersect(Range, Range)
Returns the intersection of two Range objects.
public static Range Intersect(Range range1, Range range2)
Parameter | Type | Description |
---|---|---|
range1 | Range | The first Range to examine. |
range2 | Range | The second Range to examine. |
Returns
IntersectsWith(Range)
Returns whether the range intersects with the specified Range.
public bool IntersectsWith(Range range)
Parameter | Type | Description |
---|---|---|
range | Range | The Range to check. |
Returns
Normalize()
Normalizes the range values (ensures that the maximum value is greater than or equal to the minimum).
public void Normalize()
OverlapsWith(Range)
public bool OverlapsWith(Range range)
Parameter | Type | Description |
---|---|---|
range | Range | The Range to examine. |
Returns
ToString()
Converts the object to a String
.
Union(Range)
public void Union(Range range)
Parameter | Type | Description |
---|---|---|
range | Range | The Range with which to merge. |
Operators
operator ==(Range, Range)
Compares two Range objects. The result specifies whether the values of the Min and Max properties of the two Range objects are equal.
public static bool operator ==(Range left, Range right)
Parameter | Type | Description |
---|---|---|
left | Range | A Range to compare. |
right | Range | A Range to compare. |
Returns
operator !=(Range, Range)
Compares two Range objects. The result specifies whether the values of the Min and Max properties of the two Range objects are unequal.
public static bool operator !=(Range left, Range right)
Parameter | Type | Description |
---|---|---|
left | Range | A Range to compare. |
right | Range | A Range to compare. |