Question

Y at-il un moyen rapide d'obtenir un List<TElement> aplati d'un ILookup<TKey, TElement> qui a été créé à partir de l'extension IEnumerable<TElement>?


Mise à jour par exemple

List<int> list = new List<int>();
var lookup = list.ToLookup(key => key);
list = lookup.?? // How to convert the lookup back to the list
Était-ce utile?

La solution

lookup.SelectMany( x => x ).ToList()

La transformation de ILookup et retour aura probablement été modifiée l'ordre, cependant.

Autres conseils

Je ne sais pas si c'est ce que vous recherchez. Pour Dictionary<> à List<>

List<TElement> list iLookUp.Values.ToList<TElement>();

de List<> à Dictionary<>

var dict = list.Cast<TElement>().ToDictionary(t => t.Id, t => t.Description);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top