Range Range Range Range Struct

Definition

Represents a range that has start and end indexes.

public value class Range : IEquatable<Range>
public struct Range : IEquatable<Range>
type Range = struct
Public Structure Range
Implements IEquatable(Of Range)
Inheritance
Implements

Remarks

Range is used by the C# compiler to support the range syntax:

int[] someArray = new int[5] { 1, 2, 3, 4, 5 };
int[] subArray1 = someArray[0..2];               // { 1, 2 }
int[] subArray2 = someArray[1..^0];              // { 2, 3, 4, 5 }

Constructors

Range(Index, Index) Range(Index, Index) Range(Index, Index) Range(Index, Index)

Instantiates a new Range instance with the specified starting and ending indexes.

Properties

All All All All

Gets a Range object that starts from the first element to the end.

End End End End

Gets an Index that represents the exclusive end index of the range.

Start Start Start Start

Gets the inclusive start index of the Range.

Methods

EndAt(Index) EndAt(Index) EndAt(Index) EndAt(Index)

Creates a Range object starting from the first element in the collection to a specified end index.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Returns a value that indicates whether the current instance is equal to a specified object.

Equals(Range) Equals(Range) Equals(Range) Equals(Range)

Returns a value that indicates whether the current instance is equal to another Range object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Returns the hash code for this instance.

GetOffsetAndLength(Int32) GetOffsetAndLength(Int32) GetOffsetAndLength(Int32) GetOffsetAndLength(Int32)

Calculates the start offset and length of the range object using a collection length.

StartAt(Index) StartAt(Index) StartAt(Index) StartAt(Index)

Returns a new Range instance starting from a specified start index to the end of the collection.

ToString() ToString() ToString() ToString()

Returns the string representation of the current Range object.

Applies to