Add an element with the specified key and value into the Hashtable in CSharp
Description
The following code shows how to add an element with the specified key and value into the Hashtable.
Example
using System; /*from w ww. j a va 2 s .c o m*/
using System.Collections;
class HashtableDemo {
public static void Main() {
Hashtable ht = new Hashtable();
ht.Add("a", "A");
ht.Add("b", "B");
ht.Add("c", "C");
ht.Add("e", "E");
// Get a collection of the keys.
ICollection c = ht.Keys;
foreach(string str in c)
Console.WriteLine(str + ": " + ht[str]);
}
}
The code above generates the following result.