SortedDictionary<TKey, TValue>.ContainsKey(TKey) Method is used to check whether the SortedDictionary contains an element with the specified key or not.
Syntax:
public bool ContainsKey (TKey key);
Here, the
key is the Key which is to be located in the SortedDictionary.
Returns Value: This method will return
true if the Dictionary contains an element with the specified key otherwise, it returns
false.
Exception: This method will give
ArgumentNullException if the
key is null.
Below are the programs to illustrate the use of the above-discussed method:
Example 1:
Output:
Key : 4 is present
Example 2: