語言

IList<T>.Item[Int32] 屬性

定義

取得或設定位於指定索引處的專案。

public:
 property T default[int] { T get(int index); void set(int index, T value); };
public T this[int index] { get; set; }
member this.Item(int) : 'T with get, set
Default Public Property Item(index As Integer) As T

參數

index
Int32

要取得或設定的元素的零基指數。

屬性值

T

位於指定索引的元素。

例外狀況

index 在 中 不是有效的索引 IList<T>。

屬性為設定,且為 IList<T> 唯讀。

備註

此特性可透過以下語法存取集合中的特定元素: myCollection[index]。

C# 語言使用 this 關鍵字來定義索引器,而非實作該 Item[] 屬性。 Visual Basic 將 Item[] 實作為 default 屬性,提供相同的索引功能。

適用於

另請參閱