Write the syntax of foreach loop with hashtable and get the key, value pair from the hashtable?
Interview question and answer by:
Peermohamedmydeen | Posted on: 9/14/2010 | Category:
C# Interview questions | Views: 2646 | |
Points: 40
Answer:
HashTable ht = new HashTable();
ht.Add(1,"A");
ht.Add(2,"B");
ht.Add(3,"C");
foreach(DictionaryEntry de in ht)
{
Console.WriteLine(string.Format("Key : {0} Value: {1}", de.Key.ToString(),de.Value.ToString()));
}
Asked In: Preliminary Technical Written Test
|
Alert Moderator
Found interesting? Add this to: