How to count a dictionary items in C#

The Count property gets the number of key/value pairs in a Dictionary.
Dictionary<string, Int16> AuthorList = new Dictionary<string, Int16>();  
   
AuthorList.Add("Mahesh Chand", 35);  
AuthorList.Add("Mike Gold", 25);  
AuthorList.Add("Praveen Kumar", 29);  
AuthorList.Add("Raj Beniwal", 21);  
AuthorList.Add("Dinesh Beniwal", 84);

The following code snippet displays the number of items in a dictionary:

Console.WriteLine("Count: {0}", AuthorList.Count);

Output

 
 


Similar Articles
Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.