Hashtable.ContainsKey : HashTable « System.Collections « C# / C Sharp by API






Hashtable.ContainsKey

  
using System;
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");

    foreach (string myKey in myHashtable.Keys)
    {
      Console.WriteLine("myKey = " + myKey);
    }
    foreach(string myValue in myHashtable.Values)
    {
      Console.WriteLine("myValue = " + myValue);
    }
    
    if (myHashtable.ContainsKey("FL"))
    {
      Console.WriteLine("myHashtable contains the key FL");
    }
  }
}

   
    
  








Related examples in the same category

1.HashTable.Keys
2.HashTable.Remove
3.Hashtable.Add
4.Hashtable.ContainsValue
5.Hashtable.Keys.CopyTo
6.Hashtable.Synchronized
7.Hashtable.Values
8.Hashtable.Values.CopyTo