ArrayList.Count 屬性

定義

取得 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. 如果 Count 在加入元素時超過 Capacity,則在複製舊的專案並新增新專案之前,會重新配置內部陣列,以自動增加容量。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.

適用於

另請參閱