StringCollection.IList.Insert(Int32, Object) 方法

定義

將項目插入至 StringCollection 中指定的索引位置。

 virtual void System.Collections.IList.Insert(int index, System::Object ^ value) = System::Collections::IList::Insert;
void IList.Insert (int index, object value);
void IList.Insert (int index, object? value);
abstract member System.Collections.IList.Insert : int * obj -> unit
override this.System.Collections.IList.Insert : int * obj -> unit
Sub Insert (index As Integer, value As Object) Implements IList.Insert

參數

index
Int32

應在 value 插入以零為起始的索引。

value
Object

要插入的 Object。 這個值可以是 null

實作

例外狀況

index 小於零。

-或-

index 大於 Count

StringCollection 為唯讀。

-或-

StringCollection 具有固定的大小。

備註

如果 Count 已經等於容量,則會藉由自動重新配置內部陣列來增加 的容量 StringCollection ,並在新增專案之前,將現有的元素複製到新的陣列。

如果 index 等於 Countvalue 則會新增至 的 StringCollection 結尾。

在連續項目的集合 (例如清單) 中,後面接著插入點的項目會向下移動以容納新項目。 如果集合具有索引,則移動之項目的索引也會更新。 集合的項目若在概念上群組成 Bucket (例如雜湊資料表),則不適用這項行為。

這個方法是 O (n) 作業,其中 nCount

適用於

另請參閱