How to count a dictionary items with 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);


Download complete free book: Dictionary Programming with C#



Up Next
    Ebook Download
    View all
    Learn
    View all