Created
April 24, 2012 08:31
-
-
Save tnngo2/2477903 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 SortedCollection | |
{ | |
static void Main(string[] args) | |
{ | |
SortedList objSortList = new SortedList(); | |
objSortList.Add("John", "Administration"); | |
objSortList.Add("Jack", "Human Resource"); | |
objSortList.Add("Peter", "Finance"); | |
objSortList.Add("Joel", "Marketing"); | |
Console.WriteLine("Original values stored in the sorted list"); | |
Console.WriteLine("Key \t\t Values"); | |
for (int i = 0; i < objSortList.Count; i++) | |
{ | |
Console.WriteLine(objSortList.GetKey(i) + "\t\t" + objSortList.GetByIndex(i)); | |
} | |
if (!objSortList.ContainsKey("Jerry")) | |
{ | |
objSortList.Add("Jerry","Construction"); | |
} | |
objSortList["Peter"] = "Engineering"; | |
objSortList["Jerry"] = "Information Technology"; | |
Console.WriteLine(); | |
Console.WriteLine("Update values stored in hash table"); | |
Console.WriteLine("Key \t\t Values"); | |
for (int i = 0; i < objSortList.Count; i++) | |
{ | |
Console.WriteLine(objSortList.GetKey(i) + " \t\t" + objSortList.GetByIndex(i)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment