NameObjectCollectionBase.Count 属性

定义

获取包含在 NameObjectCollectionBase 实例中的键/值对的数目。Gets the number of key/value pairs contained in the NameObjectCollectionBase instance.

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

属性值

包含在 NameObjectCollectionBase 实例中的键/值对的数目。The number of key/value pairs contained in the NameObjectCollectionBase instance.

实现

注解

容量是 NameObjectCollectionBase 可以存储的元素数。The capacity is the number of elements that the NameObjectCollectionBase can store. Count 是实际处于 NameObjectCollectionBase中的元素的数目。Count is the number of elements that are actually in the NameObjectCollectionBase.

容量始终大于或等于 CountThe capacity is always greater than or equal to Count. 如果在添加元素时 Count 超过容量,则会自动重新分配内部数组,然后再复制旧元素并添加新元素,从而自动增加容量。If Count exceeds the 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.

适用于