IList<T>.Item[Int32] 屬性

定義

在指定的索引位置上取得或設定項目。Gets or sets the element at the specified index.

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

要取得或設定的以零為起始元素索引。The zero-based index of the element to get or set.

屬性值

T

在指定索引上的項目。The element at the specified index.

例外狀況

index 不是 IList<T> 中的有效索引。index is not a valid index in the IList<T>.

屬性已設定,而且 IList<T> 是唯讀的。The property is set and the IList<T> is read-only.

備註

這個屬性可透過下列語法存取集合中的特定元素:myCollection[index]This property provides the ability to access a specific element in the collection by using the following syntax: myCollection[index].

C # 語言使用 this 關鍵字來定義索引子,而不是執行 Item[] 屬性。The C# language uses the this keyword to define the indexers instead of implementing the Item[] property. Visual Basic 會實 Item[] 作為 預設屬性,以提供相同的編制索引功能。Visual Basic implements Item[] as a default property, which provides the same indexing functionality.

適用於

另請參閱