語言

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 等於 Count, value 則 加到末 StringCollection尾。

在連續元素的集合中,例如列表,插入點後的元素會向下移動以容納新元素。 若集合被索引,移動元素的索引也會同步更新。 此行為不適用於將元素概念上分組為桶的集合,例如雜湊表。

此方法是一個 O(n) 運算,其中 n 為 Count。

適用於

另請參閱