Get or set the value associated with the specified key in CSharp

Description

The following code shows how to get or set the value associated with the specified key.

Example


using System;/*ww w . ja va  2 s  . co  m*/
using System.Collections;

class MainClass
{
    public static void Main()
    {
        Hashtable    hash = new Hashtable();
        hash["A"] = "1";
        
        foreach (string firstName in hash.Keys)
        {
            Console.WriteLine("{0} {1}", firstName, hash[firstName]);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary