c# - How to use Lambda to merge two Dictionary with List<string> contain in Dictionaries -


i have 2 dictionaries of type dictionary<string, list<string>> how merge these 2 dictionaries 1 dictionary dictionary<string, list<string>>.

list<string> lsta = new list<string> { "a", "b", "c", "d" }; list<string> lstb = new list<string> { "1", "2", "3", "4" }; var dica = new dictionary<string, list<string>> { { "0", lsta } }; var dicb = new dictionary<string, list<string>> { { "0", lstb } };  var mergedic = dica.concat(dicb)                    .groupby(t => t.key)                    .todictionary(k => k.key, d => d.select(k => k.value)                    .tolist()); 

change d.select d.selectmany

var mergedic = dica.concat(dicb)                    .groupby(t => t.key)                    .todictionary(k => k.key, d => d.selectmany(k => k.value)                    .tolist()); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -