StringCollection.Item[Int32] 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定位於指定索引處的專案。
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
以零為基礎的索引,要取得或設定。
屬性值
位於指定索引的元素。
例外狀況
備註
此特性可透過以下語法存取集合中的特定元素: myCollection[index]。
StringCollection 接受 null 為有效值,並允許重複元素。
C# 語言使用 this 關鍵字來定義索引器,而非實作該 Item[] 屬性。 Visual Basic 將 Item[] 實作為 default 屬性,提供相同的索引功能。
取得此屬性的值為 O(1) 運算;設定屬性也是 O(1) 操作。