ネットILookup <処理鍵、TElement>を平坦化する方法は、リストにありますか?
質問
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
へと再びが最も可能性が高いしかし、順序を変更しています。
他のヒント
わからない、これはあなたが後にしているものです場合。 Dictionary<>
にList<>
List<TElement> list iLookUp.Values.ToList<TElement>();
List<>
からDictionary<>
var dict = list.Cast<TElement>().ToDictionary(t => t.Id, t => t.Description);
所属していません StackOverflow