Guest User

Untitled

a guest
Jan 21st, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. Dictionary<string, List<SomeType>> GetKeyPairValues()
  2. {
  3. // get nested dictionary from this.myDict
  4. }
  5.  
  6. Dictionary<string, List<SomeType>> GetKeyPairValues()
  7. {
  8. return dic.Values.SelectMany(d => d)
  9. .GroupBy(p => p.Key)
  10. .ToDictionary(g => g.Key,
  11. g => g.SelectMany(pair => pair.Value)
  12. .ToList());
  13. }
  14.  
  15. return myDict.Values.ToDictionary(x => x.Keys, x => x.Values);
  16.  
  17. Dictionary<string, List<SomeType>> GetKeyPairValues()
  18. {
  19. foreach (var pair in dict)
  20. {
  21. yield return pair.Value;
  22. }
  23. }
  24.  
  25. var dictionary = new Dictionary<string, Dictionary<string, List<int>>>();//initialize your source dictionary
  26. var mergedDictionary = dictionary.SelectMany(d => d.Value).ToDictionary(k=>k.Key, k=>k.Value);
  27.  
  28. IDictionary<string, Dictionary<string, List<SomeType>>> dict = new Dictionary<string, Dictionary<string, List<SomeType>>>();
  29. ICollection<Dictionary<string, List<SomeType>>> = dict.Values;
Add Comment
Please, Sign In to add comment