Index Index Index Index Struct

定义

表示一种可用于从开头或从结尾索引集合的类型。Represents a type that 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)
继承
实现

注解

IndexC#编译器使用来支持新的索引语法: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

构造函数

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

通过指定索引位置和指示从集合开头还是从结尾开始索引的值,初始化新的 IndexInitializes 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.

属性

End End End End

获取指向最后一个元素以外的 IndexGets 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

获取一个 Index,它指向集合中的第一个元素。Gets an Index that points to the first element of a collection.

Value Value Value Value

获取索引值。Gets the index value.

方法

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

返回一个值,该值指示当前对象是否与另一个 Index 对象相等。Returns a value that indicates whether the current object is equal to another Index object.

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

指示当前 Index 对象是否与指定的对象相等。Indicates whether the current Index object is equal to a specified object.

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

在指定索引位置处,从集合末尾创建 IndexCreates an Index from the end of a collection at a specified index position.

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

在集合开头处,从指定索引中创建 IndexCreate 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 of the collection using the given collection length.

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

返回当前 Index 实例的字符串表示形式。Returns the string representation of the current Index instance.

操作员

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

将整数转换为索引。Converts integer number to an Index.

适用于