using System.Collections.Generic;
public static void Main()
Dictionary<string, string> dict_inner = new Dictionary<string, string>();
dict_inner.Add("new1", "inner_val1");
dict_inner.Add("new2", "inner_val2");
Dictionary<string, string> dict_inner2 = new Dictionary<string, string>();
dict_inner2.Add("halo1", "inner_val1");
dict_inner2.Add("halo2", "inner_val2");
Dictionary<string, Dictionary<string, string>> dict_outer = new Dictionary<string, Dictionary<string, string>>();
dict_outer.Add("outer1", dict_inner);
dict_outer.Add("outer2", dict_inner2);
Console.WriteLine("Directly get all inner object \n");
var result2 = dict_outer.SelectMany(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
foreach(var res2 in result2)
Console.WriteLine(res2.Key);
Console.WriteLine(res2.Value);
Console.WriteLine("multiple outer object \n");
var intendedResult = dict_outer.ToDictionary(d => d.Key, d => d.Value);
foreach(var res in intendedResult)
var i = res.Value.ToDictionary(d => d.Key, d => d.Value);
var count = res.Value.Count();
Console.WriteLine("outer key:" + res.Key + "(" + count + ")");
Console.WriteLine("-------------");
Console.WriteLine(res2.Key);
Console.WriteLine(res2.Value);
Console.WriteLine("--------");