.NET 4,我有
public class Humi
{
public int huKey { get; set; }
public string huVal { get; set; }
}
在另一个类中是这个方法中的代码:
IEnumerable<Humi> someHumi = new List<Humi>(); //This is actually ISingleResult that comes from a LinqToSql-fronted sproc but I don't think is relevant for my question
var humia = new Humi { huKey = 1 , huVal = "a"};
var humib = new Humi { huKey = 1 , huVal = "b" };
var humic = new Humi { huKey = 2 , huVal = "c" };
var humid = new Humi { huKey = 2 , huVal = "d" };
我想创建一个 IDictionary<int,string[]>
键 1 包含 ["a","b"] 键 2 包含 ["c","d"]
谁能指出使用 Linq 进行这种转换的一种不错的方法?
谢谢。