Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

Index Struct

Definition

Namespace:
System
Assemblies:
netstandard.dll, System.Runtime.dll
Assembly:
System.Runtime.dll
Assembly:
Microsoft.Bcl.Memory.dll
Assembly:
netstandard.dll
Package:
Microsoft.Bcl.Memory v11.0.0-preview.5.26302.115
Source:
Index.cs
Source:
Index.cs
Source:
Index.cs
Source:
Index.cs
Source:
Index.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Represents a type that can be used to index a collection either from the beginning or the end.

public value class Index : IEquatable<Index>
public readonly 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 ^ or "index from end" operator:

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

Constructors

Name Description
Index(Int32, Boolean)

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

Properties

Name Description
End

Gets an Index that points beyond the last element.

IsFromEnd

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

Start

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

Value

Gets the index value.

Methods

Name Description
Equals(Index)

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

Equals(Object)

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

FromEnd(Int32)

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

FromStart(Int32)

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

GetHashCode()

Returns the hash code for this instance.

GetOffset(Int32)

Calculates the offset from the start of the collection using the specified collection length.

ToString()

Returns the string representation of the current Index instance.

Operators

Name Description
Implicit(Int32 to Index)

Converts an integer number to an Index.

Applies to


Feedback

Was this page helpful?