ArrayList.Count ArrayList.Count ArrayList.Count ArrayList.Count Property

定义

获取 ArrayList 中实际包含的元素数。Gets the number of elements actually contained in the ArrayList.

public:
 virtual property int Count { int get(); };
public virtual int Count { get; }
member this.Count : int
Public Overridable ReadOnly Property Count As Integer

属性值

ArrayList 中实际包含的元素数。The number of elements actually contained in the ArrayList.

实现

注解

CapacityArrayList可以存储的元素数。Capacity is the number of elements that the ArrayList can store. Count实际在中ArrayList的元素的数目。Count is the number of elements that are actually in the ArrayList.

Capacity始终大于或等于CountCapacity is always greater than or equal to Count. 如果CountCapacity添加元素时超过, 则会通过在复制旧元素并添加新元素之前重新分配内部数组来自动增加容量。If Count exceeds Capacity while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements.

检索此属性的值的运算复杂度为 O(1)。Retrieving the value of this property is an O(1) operation.

适用于

另请参阅