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
foreach (int key in table.Keys)
{
//Console.WriteLine(key);
}
//遍历表的值
foreach (Hashtable obj in table.Values)
{
Console.WriteLine(obj);
Console.WriteLine("-----------------------------------------");
//遍历key
foreach (Object v in obj.Keys)
{
Console.WriteLine(v);
}
Console.WriteLine("-----------------------------------------");
//遍历值
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#遍历哈希表
分享地址:http://scyingshan.cn/article/pipcei.html