Show / Hide Table of Contents

Struct Range<T>

Defines a range of values.

Implements
IRange<T>
IEquatable<IRange<T>>
ICloneable<Range<T>>
ICloneable
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: TheXDS.MCART.Types
Assembly: MCART.dll
Syntax
public struct Range<T> : IRange<T>, IEquatable<IRange<T>>, ICloneable<Range<T>>, ICloneable where T : IComparable<T>
Type Parameters
Name Description
T

Base type of the value range.

Constructors

| Edit this page View Source

Range(T)

Initializes a new instance of the Range<T> structure.

Declaration
public Range(T maximum)
Parameters
Type Name Description
T maximum

Maximum value of the range, inclusive.

| Edit this page View Source

Range(T, bool)

Initializes a new instance of the Range<T> structure.

Declaration
public Range(T maximum, bool inclusive)
Parameters
Type Name Description
T maximum

Maximum value of the range.

bool inclusive

If set to true, the maximum value will be included in the range.

| Edit this page View Source

Range(T, T)

Initializes a new instance of the Range<T> structure.

Declaration
public Range(T minimum, T maximum)
Parameters
Type Name Description
T minimum

Minimum value of the range, inclusive.

T maximum

Maximum value of the range, inclusive.

| Edit this page View Source

Range(T, T, bool)

Initializes a new instance of the Range<T> structure.

Declaration
public Range(T minimum, T maximum, bool inclusive)
Parameters
Type Name Description
T minimum

Minimum value of the range.

T maximum

Maximum value of the range.

bool inclusive

If set to true, both minimum and maximum values will be included in the range.

| Edit this page View Source

Range(T, T, bool, bool)

Initializes a new instance of the Range<T> structure.

Declaration
public Range(T minimum, T maximum, bool minInclusive, bool maxInclusive)
Parameters
Type Name Description
T minimum

Minimum value of the range.

T maximum

Maximum value of the range.

bool minInclusive

If set to true, the minimum value will be included in the range.

bool maxInclusive

If set to true, the maximum value will be included in the range.

Properties

| Edit this page View Source

MaxInclusive

Gets or sets a value that determines whether the maximum value is part of the range.

Declaration
public bool MaxInclusive { readonly get; set; }
Property Value
Type Description
bool
| Edit this page View Source

Maximum

Maximum value of the range.

Declaration
public T Maximum { readonly get; set; }
Property Value
Type Description
T
| Edit this page View Source

MinInclusive

Gets or sets a value that determines whether the minimum value is part of the range.

Declaration
public bool MinInclusive { readonly get; set; }
Property Value
Type Description
bool
| Edit this page View Source

Minimum

Minimum value of the range.

Declaration
public T Minimum { readonly get; set; }
Property Value
Type Description
T

Methods

| Edit this page View Source

Clone()

Creates a copy of this instance.

Declaration
public readonly Range<T> Clone()
Returns
Type Description
Range<T>

A copy of this instance of type Range<T>.

| Edit this page View Source

Equals(object?)

Indicates whether this instance and a specified object are equal.

Declaration
public override readonly bool Equals(object? obj)
Parameters
Type Name Description
object obj

The object to compare with the current instance.

Returns
Type Description
bool

true if this instance and obj are equal, false otherwise.

Overrides
ValueType.Equals(object)
| Edit this page View Source

Equals(IRange<T>?)

Indicates whether this instance and a specified object are equal.

Declaration
public readonly bool Equals(IRange<T>? other)
Parameters
Type Name Description
IRange<T> other

The object to compare with the current instance.

Returns
Type Description
bool

true if this instance and other are equal, false otherwise.

| Edit this page View Source

GetHashCode()

Returns the hash code for this instance.

Declaration
public override readonly int GetHashCode()
Returns
Type Description
int

The hash code for this instance.

Overrides
ValueType.GetHashCode()
| Edit this page View Source

Intersect(IRange<T>)

Gets an intersection range from this and another specified range.

Declaration
public readonly Range<T> Intersect(IRange<T> other)
Parameters
Type Name Description
IRange<T> other

Range to intersect.

Returns
Type Description
Range<T>

The intersection between this range and other.

| Edit this page View Source

Intersects(IRange<T>)

Determines if a Range<T> intersects with this one.

Declaration
public readonly bool Intersects(IRange<T> other)
Parameters
Type Name Description
IRange<T> other

Range to check.

Returns
Type Description
bool

true if other intersects this Range<T>, false otherwise.

| Edit this page View Source

IsWithin(T)

Checks if a T value is within this Range<T>.

Declaration
public readonly bool IsWithin(T value)
Parameters
Type Name Description
T value

Value to check.

Returns
Type Description
bool

true if the value is within this Range<T>, false otherwise.

| Edit this page View Source

Join(IRange<T>)

Combines this Range<T> with another.

Declaration
public readonly Range<T> Join(IRange<T> other)
Parameters
Type Name Description
IRange<T> other
Returns
Type Description
Range<T>
| Edit this page View Source

Parse(string)

Creates a Range<T> from a string.

Declaration
[RequiresUnreferencedCode("The method obtains a collection of types without direct references, so it is not compatible with trimming.")]
[RequiresDynamicCode("The method makes calls to dynamic code, so it is not compatible with trimming.")]
public static Range<T> Parse(string value)
Parameters
Type Name Description
string value

Value from which to create a Range<T>.

Returns
Type Description
Range<T>

The created Range<T>.

Exceptions
Type Condition
FormatException

Thrown if the conversion fails.

| Edit this page View Source

ToString()

Converts this Range<T> to its string representation.

Declaration
public override readonly string ToString()
Returns
Type Description
string

A string representation of this Range<T>.

Overrides
ValueType.ToString()
| Edit this page View Source

TryParse(string, out Range<T>)

Attempts to create a Range<T> from a string.

Declaration
[RequiresUnreferencedCode("The method obtains a collection of types without direct references, so it is not compatible with trimming.")]
[RequiresDynamicCode("The method makes calls to dynamic code, so it is not compatible with trimming.")]
public static bool TryParse(string value, out Range<T> range)
Parameters
Type Name Description
string value

Value from which to create a Range<T>.

Range<T> range

The created Range<T>.

Returns
Type Description
bool

true if the conversion succeeded, false otherwise.

Operators

| Edit this page View Source

operator +(Range<T>, Range<T>)

Unites two value ranges.

Declaration
public static Range<T> operator +(Range<T> left, Range<T> right)
Parameters
Type Name Description
Range<T> left

Left operand.

Range<T> right

Right operand.

Returns
Type Description
Range<T>

The union of both Range<T>. If the ranges don't intersect, all missing values will be included.

| Edit this page View Source

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

Compares two instances of Range<T> for equality.

Declaration
public static bool operator ==(Range<T> left, Range<T> right)
Parameters
Type Name Description
Range<T> left

Object to compare.

Range<T> right

Object to compare against.

Returns
Type Description
bool

true if both instances are equal, false otherwise.

| Edit this page View Source

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

Compares two instances of Range<T>, and returns true if they are different from each other.

Declaration
public static bool operator !=(Range<T> left, Range<T> right)
Parameters
Type Name Description
Range<T> left

Object to compare.

Range<T> right

Object to compare against.

Returns
Type Description
bool

true if both instances are different, false otherwise.

Implements

IRange<T>
IEquatable<T>
ICloneable<T>
ICloneable

Extension Methods

Objects.ShallowCopyTo(object, object, Type)
ObjectExtensions.FieldsOf<T>(object)
ObjectExtensions.GetAttribute<T>(object)
ObjectExtensions.GetAttributes<T>(object)
ObjectExtensions.HasAttrValue<TAttribute, TValue>(object, out TValue)
ObjectExtensions.HasAttribute<T>(object)
ObjectExtensions.HasAttribute<T>(object, out T?)
ObjectExtensions.HasAttributes<T>(object, out IEnumerable<T>?)
ObjectExtensions.Is(object?, object?)
ObjectExtensions.IsEither(object, IEnumerable)
ObjectExtensions.IsEither(object, params object[])
ObjectExtensions.IsNeither(object, IEnumerable)
ObjectExtensions.IsNeither(object, params object[])
ObjectExtensions.IsNot(object?, object?)
ObjectExtensions.PropertiesOf<T>(object)
ObjectExtensions.WhichAre(object, IEnumerable<object>)
ObjectExtensions.WhichAre(object, params object[])
Objects.Itself<T>(T)
Objects.ShallowClone<T>(T)
Objects.ShallowCopyTo<T>(T, T)
CollectionExtensions.PushInto<TItem, TCollection>(TItem, ICollection<TCollection>)
DictionaryExtensions.PushInto<TKey, TValue>(TValue, TKey, IDictionary<TKey, TValue>)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX