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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -