C# OrderedDictionary Contains
Description
OrderedDictionary Contains
determines whether the
OrderedDictionary collection contains a specific key.
Syntax
OrderedDictionary.Contains
has the following syntax.
public bool Contains(
Object key
)
Parameters
OrderedDictionary.Contains
has the following parameters.
key
- The key to locate in the OrderedDictionary collection.
Returns
OrderedDictionary.Contains
method returns true if the OrderedDictionary collection contains an element with the specified
key; otherwise, false.
Example
/* w w w .j a v a2 s . co m*/
using System;
using System.Collections;
using System.Collections.Specialized;
public class SamplesStringCollection {
public static void Main() {
OrderedDictionary myOrderedDictionary = new OrderedDictionary();
myOrderedDictionary.Add("testKey1", "testValue1");
myOrderedDictionary.Add("testKey2", "testValue2");
myOrderedDictionary.Add("testKey3", "testValue3");
if (myOrderedDictionary.Contains("keyToDelete"))
{
myOrderedDictionary.Remove("keyToDelete");
}
}
}