我建了一个hashtable,但是不知道怎么用linq查询。谁来看看 Hashtable ht = new Hashtable();
ht.Add("a", 123);
ht.Add("b", 1234);
ht.Add("c", 1235); var result =
from n in ht
where n="a"
select n;
Console.WriteLine(result);错误 1 未能找到源类型“System.Collections.Hashtable”的查询模式的实现。找不到“Where”。请考虑显式指定范围变量“n”的类型。
ht.Add("a", 123);
ht.Add("b", 1234);
ht.Add("c", 1235); var result =
from n in ht
where n="a"
select n;
Console.WriteLine(result);错误 1 未能找到源类型“System.Collections.Hashtable”的查询模式的实现。找不到“Where”。请考虑显式指定范围变量“n”的类型。
var result =
from n in ht.Cast<DictionaryEntry>()
where n.Key=="a"
select n;
Dictionary<string, int> dict = new Dictionary<string, int>();
var ret = from kp in dict where kp.Key == "a" select kp;