IList<T>.Insert(Int32, T) 方法

定義

將項目插入位於指定索引的 IList<T>

public:
 void Insert(int index, T item);
public void Insert (int index, T item);
abstract member Insert : int * 'T -> unit
Public Sub Insert (index As Integer, item As T)

參數

index
Int32

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

item
T

要插入 IList<T> 的物件。

例外狀況

index 不是 IList<T> 中的有效索引。

備註

如果 index 等於在 IList<T> 中的項目數,則會將 item 附加至清單。

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

適用於

另請參閱