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

定義

將項目插入至指定之索引的 Collection 物件。Inserts an item to the Collection object at the specified index.

 virtual void IListInsert(int index, System::Object ^ value) = System::Collections::IList::Insert;
void IList.Insert (int index, object value);
Sub IListInsert (index As Integer, value As Object) Implements IList.Insert

參數

index
Int32

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

value
Object

要插入至 Object 物件的 CollectionThe Object to insert into the Collection object.

例外狀況

index 不是 Collection 物件中的有效索引。index is not a valid index in the Collection object.

Collection 物件為唯讀。The Collection object is read-only.

-或--or- Collection 物件具有固定的大小。The Collection object has a fixed size.

valueCollection 物件中的 null 參考。value is null reference in the Collection object.

備註

如果 index 等於 Collection 物件中的專案數,則 value 會附加至結尾。If index equals the number of items in the Collection object, then value is appended to the end.

在連續項目的集合 (例如清單) 中,後面接著插入點的項目會向下移動以容納新項目。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.

適用於

另請參閱