ArraySegment<T>.IList<T>.Item[Int32] プロパティ

定義

指定したインデックスにある要素を取得または設定します。

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

パラメーター

index
Int32

取得または設定する要素の、0 から始まるインデックス番号。

プロパティ値

T

指定したインデックス位置にある要素。

実装

例外

indexArraySegment<T> の有効なインデックスではありません。

このプロパティが設定されていますが、配列セグメントが読み取り専用です。

注釈

このメンバーは、明示的なインターフェイス メンバーの実装です。 次の例に示すように、インスタンスが ArraySegment<T> インターフェイスに IList<T> キャストされている場合にのみ使用できます。

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

適用対象

製品 バージョン
.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
.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
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0