拡張機能から作成され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);