Index Struktura
Definice
Představuje typ, který lze použít k indexování kolekce buď od počátečního, nebo konce.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)
- Dědičnost
- Implementuje
Poznámky
Index je používán kompilátorem jazyka C# k podpoře nové syntaxe indexu: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
Konstruktory
| Index(Int32, Boolean) |
Inicializuje novou Index se zadanou indexovou pozicí a hodnotou, která označuje, zda je index od začátku nebo na konci kolekce.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. |
Vlastnosti
| End |
Získá Index body za posledním prvkem.Gets an Index that points beyond the last element. |
| IsFromEnd |
Získá hodnotu, která označuje, zda je index od začátku nebo na konci.Gets a value that indicates whether the index is from the start or the end. |
| Start |
Načte objekt Index , který odkazuje na první prvek kolekce.Gets an Index that points to the first element of a collection. |
| Value |
Získá hodnotu indexu.Gets the index value. |
Metody
| Equals(Index) |
Vrátí hodnotu, která označuje, zda je aktuální objekt roven jinému Index objektu.Returns a value that indicates whether the current object is equal to another Index object. |
| Equals(Object) |
Označuje, zda je aktuální objekt indexu roven zadanému objektu.Indicates whether the current Index object is equal to a specified object. |
| FromEnd(Int32) |
Vytvoří Index z konce kolekce v zadané pozici indexu.Creates an Index from the end of a collection at a specified index position. |
| FromStart(Int32) |
Vytvoří Index ze zadaného indexu na začátku kolekce.Create an Index from the specified index at the start of a collection. |
| GetHashCode() |
Vrátí hodnotu hash pro tuto instanci.Returns the hash code for this instance. |
| GetOffset(Int32) |
Vypočítá posun od začátku kolekce pomocí zadané délky kolekce.Calculates the offset from the start of the collection using the given collection length. |
| ToString() |
Vrátí řetězcovou reprezentaci aktuální Index instance.Returns the string representation of the current Index instance. |
Operátory
| Implicit(Int32 to Index) |
Převede celé číslo na index.Converts integer number to an Index. |