Check if the Hashtable contains a specific value in CSharp
Description
The following code shows how to check if the Hashtable contains a specific value.
Example
using System;/* w w w. j a v a 2s . c o m*/
using System.Collections;
class MainClass
{
public static void Main()
{
Hashtable myHashtable = new Hashtable();
myHashtable.Add("AL", "Alabama");
myHashtable.Add("CA", "California");
myHashtable.Add("FL", "Florida");
myHashtable.Add("NY", "New York");
myHashtable.Add("WY", "Wyoming");
if (myHashtable.ContainsValue("Florida"))
{
Console.WriteLine("myHashtable contains the value Florida");
}
}
}
The code above generates the following result.