Get an ICollection containing the keys in the Hashtable in CSharp
Description
The following code shows how to get an ICollection containing the keys in the Hashtable.
Example
/*from ww w .j a v a2 s .c o m*/
using System;
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.