Dictionary<TKey,TValue>.Count Dictionary<TKey,TValue>.Count Dictionary<TKey,TValue>.Count Dictionary<TKey,TValue>.Count Property

定義

取得 Dictionary<TKey,TValue> 中所包含的索引鍵/值組數目。Gets the number of key/value pairs contained in the Dictionary<TKey,TValue>.

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

屬性值

Dictionary<TKey,TValue> 中所包含的索引鍵/值組數目。The number of key/value pairs contained in the Dictionary<TKey,TValue>.

實作

備註

營運Dictionary<TKey,TValue>是的項目數,Dictionary<TKey,TValue>可以儲存。The capacity of a Dictionary<TKey,TValue> is the number of elements that the Dictionary<TKey,TValue> can store. Count屬性是在實際的項目數Dictionary<TKey,TValue>The Count property is the number of elements that are actually in the Dictionary<TKey,TValue>.

容量永遠是大於或等於CountThe capacity is always greater than or equal to Count. 如果Count超過容量加入元素時,會自動將舊的項目複製並加入新項目之前,重新配置內部陣列增加容量。If Count exceeds the capacity while adding elements, the capacity is increased by automatically reallocating the internal array before copying the old elements and adding the new elements.

取得這個屬性的值是 o (1) 的作業。Getting the value of this property is an O(1) operation.

適用於