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# 語言會使用此 關鍵詞來定義索引器,而不是實作 Item[] 屬性。 Visual Basic 會 Item[] 實作為 預設屬性,以提供相同的索引功能。

擷取此屬性的值是 O (1) 作業;設定 屬性也是 O (1) 作業。

適用於