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

Definición

Obtiene o establece el elemento en el índice especificado.

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

Parámetros

index
Int32

Índice de base cero del elemento que se va a obtener o establecer.

Valor de propiedad

T

Elemento en el índice especificado.

Implementaciones

Excepciones

index no es un índice válido para ArraySegment<T>.

La propiedad está establecida y el segmento de matrices es de solo lectura.

Comentarios

Este miembro es una implementación explícita de un miembro de interfaz. Solo se puede usar cuando la ArraySegment<T> instancia se convierte en una IList<T> interfaz, como se muestra en el ejemplo siguiente.

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

Se aplica a

Producto Versiones
.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