有没有一种快速的方法来获得扁平化List<TElement>
来自ILookup<TKey, TElement>
这是从 IEnumerable<TElement>
创建的扩展名?
更新了示例
List<int> list = new List<int>();
var lookup = list.ToLookup(key => key);
list = lookup.?? // How to convert the lookup back to the list
最佳答案
lookup.SelectMany( x => x ).ToList()
但是,转换为 ILookup
并再次返回很可能会改变顺序。
关于.net - 有没有办法将 .Net ILookup<TKey, TElement> 展平为 List<TElement>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2323369/