ArraySegment<T>.IList<T>.Item[Int32] Propriedade

Definição

Obtém ou define o elemento no índice especificado.

C#
T System.Collections.Generic.IList<T>.Item[int index] { get; set; }

Parâmetros

index
Int32

O índice com base em zero do elemento a ser obtido ou definido.

Valor da propriedade

T

O elemento no índice especificado.

Implementações

Exceções

index não é um índice válido no ArraySegment<T>.

A propriedade é definida e o segmento de matriz é somente leitura.

Comentários

Este membro é uma implementação do membro de interface explícita. Ela só pode ser usada quando a ArraySegment<T> instância é convertida em uma IList<T> interface, como mostra o exemplo a seguir.

C#
using System;
using System.Collections.Generic;

public class Example
{
   public static void Main()
   {
      String[] names = { "Adam", "Bruce", "Charles", "Daniel",
                         "Ebenezer", "Francis", "Gilbert",
                         "Henry", "Irving", "John", "Karl",
                         "Lucian", "Michael" };
      var partNames = new ArraySegment<string>(names, 2, 5);

      // Cast the ArraySegment object to an IList<string> and enumerate it.
      var list = (IList<string>) partNames;
      for (int ctr = 0; ctr <= list.Count - 1; ctr++)
         Console.WriteLine(list[ctr]);
   }
}
// The example displays the following output:
//    Charles
//    Daniel
//    Ebenezer
//    Francis
//    Gilbert

Aplica-se a

Produto Versões
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0