如何以最短的方式将字典转换为元组(C#)列表?
Dictionary<long,int> myDico = new Dictionary<long,int>();
IList<Tuple<long, int>> applyOnTree = myDico.Something();
答案 0 :(得分:3)
像这样吗?
var list = myDico.Select(x => new Tuple<long, int>(x.Key, x.Value)).ToList();
答案 1 :(得分:2)
您可以尝试
var applyOnTree = myDico.Select(x => Tuple.Create(x.Key, x.Value)).ToList();