C# Linq - Extract members of list within dictionary -
i have use case dictionary one
var foo = new dictionary<string, list<string>>()
so collection hold hierarchical data this
- key 1
- value 1
- value 2
- key 2
- value 3
and need get\project list of values ignoring keys, result be
- value 1
- value 2
- value 3
on first attempt came this
ireadonlylist<string> bar = foo.select(r => r.value.select(x => x.tostring())) .select(r => r.tostring()) .tolist();
is good?
use selectmany
:
foo.selectmany(x => x.value).tolist();
Comments
Post a Comment