StringCollection.Item[Int32] 屬性

定義

在指定的索引位置上取得或設定項目。

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

參數

index
Int32

要取得或設定的項目之以零起始的索引。

屬性值

在指定索引上的項目。

例外狀況

index 小於零。

-或-

index 等於或大於 Count

備註

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

StringCollection 接受 null 做為有效值,並允許重複的專案。

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

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

適用於

另請參閱