語言

NameObjectCollectionBase.KeysCollection.Item[Int32] 屬性

定義

取得集合指定索引的條目。

public:
 property System::String ^ default[int] { System::String ^ get(int index); };
public string this[int index] { get; }
public string? this[int index] { get; }
member this.Item(int) : string
Default Public ReadOnly Property Item(index As Integer) As String

參數

index
Int32

在集合中尋找的條目以零為基礎的索引。

屬性值

集合 String 指定索引上的條目鍵。

例外狀況

index 超出該集合有效索引範圍。

備註

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

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

取得此屬性的值為 O(1) 運算;設定屬性也是 O(1) 操作。

適用於