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