Created
April 24, 2012 08:11
-
-
Save tnngo2/2477768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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