Using System;
Using System.Collections;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Namespace an
{
public class Crystal_info
{
public static Hashtable INFO = new Hashtable ();
Static Crystal_info ()
{
Hashtable HS1 = new Hashtable ();
hs1["Item_index"] = 12000;
hs1["Crystal_type"] = 102;
hs1["Sum_count"] = 1000;
hs1["Sale_type"] = 1;
INFO[12000] = HS1;
Hashtable HS2 = new Hashtable ();
hs2["Item_index"] = 12005;
hs2["Min_price"] = 200;
hs2["Server_day"] = 20;
hs2["Sale_type"] = 2;
INFO[12005] = HS2;
}
}
public class CA
{
static void Main (string[] args)
{
Hashtable table = Crystal_info.info;
Key to traverse the table
foreach (int key in table. Keys)
{
Console.WriteLine (key);
}
Traversing the values of a table
foreach (Hashtable obj in table. Values)
{
Console.WriteLine (obj);
Console.WriteLine ("-----------------------------------------");
Traverse key
foreach (Object v in obj. Keys)
{
Console.WriteLine (v);
}
Console.WriteLine ("-----------------------------------------");
Traversing values
foreach (Object v in obj. Values)
{
Console.WriteLine (v);
}
Console.WriteLine ("-----------------------------------------");
}
foreach (Hashtable obj in menulist. Values)
DictionaryEntry en = (dictionaryentry) obj;
Console.WriteLine (en. Key);
Console.WriteLine (en. Value);
Console.WriteLine (key);
Console.WriteLine (obj. Values);
Console.WriteLine (obj);
Console.readkey ();
}
}
}
C # traversal Hash table