How to count Dictionary items in C# – Programming Code Examples
C# C# Console Application

How to count Dictionary items in C#1 min read

.Net framework Dictionary<TKey, TValue>.Count property allow us to get the number of key/value pairs contained in the Dictionary<TKey, TValue>. the dictionary Count property exists under System.Collections.Generic namespace.

Dictionary<TKey, TValue>.Count property value data type is System.Int32. this integer value represents the number of key/value pairs contained in the Dictionary<TKey, TValue>. a single key and value pair represent an element of dictionary. so by using the Count property we can get the number of elements contained in the dictionary.




the dictionary Count property implements as ICollection<T>.Count, ICollection.Count and IReadOnlyCollection<T>.Count. dictionary Count property return the number of elements that are actually exists in the Dictionary<TKey, TValue>.

the following c# example code demonstrate us how can we get the number of elements contained in the dictionary in an application.

C# Code:

Output:

How to count Dictionary items in C#

How to count Dictionary items in C# D

Leave a Comment