Check if the StringDictionary contains a specific key in CSharp
Description
The following code shows how to check if the StringDictionary contains a specific key.
Example
using System;//w w w .j av a 2s . co m
using System.Collections;
using System.Collections.Specialized;
public class SamplesStringDictionary {
public static void Main() {
StringDictionary myCol = new StringDictionary();
myCol.Add( "red", "rojo" );
myCol.Add( "green", "verde" );
myCol.Add( "blue", "azul" );
if ( myCol.ContainsKey( "red" ) )
Console.WriteLine( "contains the key " );
else
Console.WriteLine( "does not contain the key " );
}
}
The code above generates the following result.