Index Index Index Index Struct

Definition

Represent a type can be used to index a collection either from the start or the end.

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

Remarks

#

Index is used by the C# compiler to support the new index syntax:

    int[] someArray = new int[5] { 1, 2, 3, 4, 5 };
    int lastElement = someArray[^1]; // lastElement = 5

Constructors

Index(Int32, Boolean) Index(Int32, Boolean) Index(Int32, Boolean) Index(Int32, Boolean)

Initializes a new Index with a specified index position and a value that indicates if the index is from the start or the end of a collection.

Properties

End End End End

Gets an Index that points beyond the last element.

IsFromEnd IsFromEnd IsFromEnd IsFromEnd

Gets a value that indicates whether the index is from the start or the end.

Start Start Start Start

Gets an Index that points to the first element of a collection.

Value Value Value Value

Gets the index value.

Methods

Equals(Index) Equals(Index) Equals(Index) Equals(Index)

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

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

Indicates whether the current Index object is equal to a specified object.

FromEnd(Int32) FromEnd(Int32) FromEnd(Int32) FromEnd(Int32)

Creates an Index from the end of a collection at a specified index position.

FromStart(Int32) FromStart(Int32) FromStart(Int32) FromStart(Int32)

Create an Index from the specified index at the start of a collection.

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

Returns the hash code for this instance.

GetOffset(Int32) GetOffset(Int32) GetOffset(Int32) GetOffset(Int32)

Calculates the offset from the start using the given collection length.

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

Returns the string representation of the current Index instance.

Operators

Implicit(Int32 to Index) Implicit(Int32 to Index) Implicit(Int32 to Index) Implicit(Int32 to Index)

Converts integer number to an Index.

Applies to