Check if Hashtable contains a specific key in CSharp
Description
The following code shows how to check if Hashtable contains a specific key.
Example
using System;/*from w ww .j a v a 2 s. c o m*/
using System.Collections;
public class SamplesHashtable {
public static void Main() {
Hashtable myHT = new Hashtable();
myHT.Add( 0, "zero" );
myHT.Add( 1, "one" );
myHT.Add( 2, "two" );
myHT.Add( 3, "three" );
myHT.Add( 4, "four" );
Console.WriteLine(myHT.Contains( 2 ));
}
}
The code above generates the following result.