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);
list转Dictionary,码迷,mamicode.com
时间: 2024-10-27 19:26:49