ReadOnlyCollection<T>.IList.Item[Int32] 屬性

定義

取得位在指定索引處的元素。 如果您嘗試在指定索引處設定項目,就會發生 NotSupportedException

property System::Object ^ System::Collections::IList::Item[int] { System::Object ^ get(int index); void set(int index, System::Object ^ value); };
object System.Collections.IList.Item[int index] { get; set; }
object? System.Collections.IList.Item[int index] { get; set; }
member this.System.Collections.IList.Item(int) : obj with get, set
 Property Item(index As Integer) As Object Implements IList.Item

參數

index
Int32

要取得之項目的以零為起始的索引。

屬性值

在指定索引上的項目。

實作

例外狀況

index 不是 IList 中的有效索引。

如果屬性已設定,則一定會擲回。

備註

這個屬性可透過下列語法存取集合中的特定元素:myCollection[index]

C# 語言會使用此 關鍵詞來定義索引器,而不是實作 IList.Item[] 屬性。 Visual Basic 會將 IList.Item[] 實作為預設屬性,這樣會提供相同的索引功能。

擷取這個屬性的值是一種 O(1) 運算。

這個成員是明確介面成員實作, 只有在 ReadOnlyCollection<T> 執行個體轉換成 IDisposable 介面時,才能使用這個成員。

適用於