ArraySegment<T>.IList<T>.Item[Int32] Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit l’élément à l’index spécifié.
property T System::Collections::Generic::IList<T>::Item[int] { T get(int index); void set(int index, T value); };
T System.Collections.Generic.IList<T>.Item[int index] { get; set; }
member this.System.Collections.Generic.IList<T>.Item(int) : 'T with get, set
Property Item(index As Integer) As T Implements IList(Of T).Item
Paramètres
- index
- Int32
Index de base zéro de l’élément à obtenir ou définir.
Valeur de propriété
Élément à l’index spécifié.
Implémente
Exceptions
index n’est pas un index valide dans le ArraySegment<T>.
La propriété est définie et le segment de tableau est en lecture seule.
Remarques
Ce membre est une implémentation explicite de membre d’interface. Elle ne peut être utilisée que lorsque l’instance ArraySegment<T> est castée en interface IList<T> , comme l’illustre l’exemple suivant.
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
open System
let names =
[| "Adam"; "Bruce"; "Charles"; "Daniel"
"Ebenezer"; "Francis"; "Gilbert"
"Henry"; "Irving"; "John"; "Karl"
"Lucian"; "Michael" |]
let partNames = ArraySegment<string>(names, 2, 5)
// Enumerate over the ArraySegment object.
for part in partNames do
printfn $"{part}"
// The example displays the following output:
// Charles
// Daniel
// Ebenezer
// Francis
// Gilbert
Imports System.Collections.Generic
Module Example
Public Sub Main()
Dim names() As String = { "Adam", "Bruce", "Charles", "Daniel",
"Ebenezer", "Francis", "Gilbert",
"Henry", "Irving", "John", "Karl",
"Lucian", "Michael" }
Dim partNames As New ArraySegment(Of String)(names, 2, 5)
' Cast the ArraySegment object to an IList<String> and enumerate it.
Dim list = CType(partNames, IList(Of String))
For ctr As Integer = 0 To list.Count - 1
Console.WriteLine(list(ctr))
Next
End Sub
End Module
' The example displays the following output:
' Charles
' Daniel
' Ebenezer
' Francis
' Gilbert