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)
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 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 EndGets an Index that points beyond the last element.
IsFromEndGets a value that indicates whether the index is from the start or the end.
StartGets an Index that points to the first element of a collection.
ValueGets the index value.
Methods 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.
OperatorsCollaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. Additional resources In this articleRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3