IList<T>.Insert(Int32, T) IList<T>.Insert(Int32, T) IList<T>.Insert(Int32, T) IList<T>.Insert(Int32, T) Method

定義

將項目插入位於指定索引的 IList<T>Inserts an item to the IList<T> at the specified index.

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 Int32 Int32 Int32

應在 item 插入以零為起始的索引。The zero-based index at which item should be inserted.

item
T T T T

要插入 IList<T> 的物件。The object to insert into the IList<T>.

例外狀況

備註

如果 index 等於在 IList<T> 中的項目數,則會將 item 附加至清單。If index equals the number of items in the IList<T>, then item is appended to the list.

在連續項目的集合 (例如清單) 中,後面接著插入點的項目會向下移動以容納新項目。In collections of contiguous elements, such as lists, the elements that follow the insertion point move down to accommodate the new element. 如果集合具有索引,則移動之項目的索引也會更新。If the collection is indexed, the indexes of the elements that are moved are also updated. 集合的項目若在概念上群組成 Bucket (例如雜湊資料表),則不適用這項行為。This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table.

適用於

另請參閱