首页 > 代码库 > list转Dictionary

list转Dictionary

            Dictionary<Guid, int> dic = lst.ToDictionary(new Func<Test, Guid>(c => c.Id), new Func<Test, int>(c => c.Num));
//如果觉得上面的写法太复杂,还可以简化为
// Dictionary<Guid, int> dic = lst.ToDictionary(c => c.Id, c => c.Num);