CollectionBase.RemoveAt(Int32) Method


移除 CollectionBase 实例的指定索引处的元素。Removes the element at the specified index of the CollectionBase instance. 此方法不可重写。This method is not overridable.

 virtual void RemoveAt(int index);
public void RemoveAt (int index);
abstract member RemoveAt : int -> unit
override this.RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)



待删除元素的从零开始的索引。The zero-based index of the element to remove.



index 小于零。index is less than zero.

- 或 --or- index 等于或大于 Countindex is equal to or greater than Count.


在由连续的元素组成的集合(如列表)中,已移除元素下面的元素将上移以占据空出的位置。In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. 如果集合具有索引,则移动的元素的索引也将更新。If the collection is indexed, the indexes of the elements that are moved are also updated. 此行为不适用于元素按概念划分为不同存储桶的集合,如哈希表。This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table.

此方法是 O(n) 操作,其中 nCount的。This method is an O(n) operation, where n is Count.

Notes to Inheritors

此方法调用 OnValidate(Object)OnRemove(Int32, Object)OnRemoveComplete(Int32, Object)This method calls OnValidate(Object), OnRemove(Int32, Object), and OnRemoveComplete(Int32, Object).

Applies to