Find a Key

The ContainsKey method checks if a key is already exists in the SortedDictionary. The following code snippet checks if a key is already exits and if not, add one.

if (!AuthorList.ContainsKey("Mahesh Chand"))

{

AuthorList["Mahesh Chand"] = 20;

}

Learn more:

Working with SortedDictionary using C#