是否可以将var数据转换为哈希表?
Hashtable hsTest = new Hashtable();
var oFeat = (from t in db.test
where t.Product_ID == iProductID
select t);
答案 0 :(得分:1)
假设您希望将Product_ID用作哈希表中的键,并将Product_Name用作值。你可以这样做:
Hashtable hsTest = new Hashtable ();
var oFeat = (from t in db.test
where t.Product_ID == iProductID
select t);
foreach (var product in oFeat) {
hsTest[product.Product_ID] = product.Product_Name;
}