Skip to content

Instantly share code, notes, and snippets.

@tnngo2
Created April 24, 2012 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tnngo2/2477768 to your computer and use it in GitHub Desktop.
Save tnngo2/2477768 to your computer and use it in GitHub Desktop.
class HashCollection
{
static void Main(string[] args)
{
Hashtable objTable = new Hashtable();
objTable.Add(001,"John");
objTable.Add(002, "Peter");
objTable.Add(003, "James");
objTable.Add(004, "Joe");
Console.WriteLine("Number of elements in the hash table: "+objTable.Count);
ICollection objCollection = objTable.Keys;
Console.WriteLine("Original values stored in hash table are: ");
foreach (int i in objCollection)
{
Console.WriteLine(i + " : " + objTable[i]);
}
if (objTable.ContainsKey(002))
{
objTable[002] = "Patrick";
}
Console.WriteLine("----------");
foreach (int i in objCollection)
{
Console.WriteLine(i + " : " + objTable[i]
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment