using System.Diagnostics;//必须命名空间
//实例化一个HashTable对象
Hashtable ht = new Hashtable();
Stopwatch sw = new Stopwatch();
object obj = new {
url="www.laibxw.com",
err="404"
};
sw.Start();
//添加100万条数据到hash表中
for (int i = 0; i < 1000000; i++)
{
ht.Add(i, obj+i.ToString());
}
var b = (from h in ht.Cast<DictionaryEntry>() select h).Take(10);
foreach (var a in b)
{
取值
Console.WriteLine(a.Value);
}
sw.Stop();
TimeSpan ts2 = sw.Elapsed;
Console.WriteLine("----开启插入完毕----");
Console.WriteLine("共耗时{0}", ts2.TotalMilliseconds);
原文:http://www.cnblogs.com/AndyCf/p/4996016.html