ReadOnlyCollection<T>.IList.Item[Int32] ReadOnlyCollection<T>.IList.Item[Int32] ReadOnlyCollection<T>.IList.Item[Int32] Property

定義

取得位在指定索引處的元素。Gets the element at the specified index. 如果您嘗試在指定索引處設定項目,就會發生 NotSupportedExceptionA NotSupportedException occurs if you try to set the item at the specified index.

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; }
 Property Item(index As Integer) As Object Implements IList.Item

參數

index
Int32 Int32 Int32

要取得之項目的以零為起始的索引。The zero-based index of the element to get.

屬性值

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

實作

例外狀況

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

如果屬性已設定,則一定會擲回。Always thrown if the property is set.

備註

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

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

擷取這個屬性的值是一種 O(1) 運算。Retrieving the value of this property is an O(1) operation.

這個成員是明確介面成員實作,This member is an explicit interface member implementation. 只有在 ReadOnlyCollection<T> 執行個體轉換成 IDisposable 介面時,才能使用這個成員。It can be used only when the ReadOnlyCollection<T> instance is cast to an IDisposable interface.

適用於