Dictionary<string, Dictionary<string, string>> objData = new Dictionary<string, Dictionary<string, string>>();
//Assign data to nested dictionary
objData.Add("A1", new Dictionary<string, string>() { { "motor1", "A1" } });
objData["A1"].Add("motor2", "A2");
objData["A1"].Add("motor3", "A3");
objData.Add("B1", new Dictionary<string, string>() { { "motorb1", "B1" } });
objData["B1"].Add("motorb2", "B2");
objData["B1"].Add("motorb3", "B3");
//Read data from nested dictionary
foreach (var outerDict in objData)
{
var innerDict = outerDict.Value;
foreach (var innerDictValue in innerDict)
{
Console.WriteLine(outerDict.Key + " " + innerDictValue.Key + " " + innerDictValue.Value);
}
}
//Assign data to nested dictionary
objData.Add("A1", new Dictionary<string, string>() { { "motor1", "A1" } });
objData["A1"].Add("motor2", "A2");
objData["A1"].Add("motor3", "A3");
objData.Add("B1", new Dictionary<string, string>() { { "motorb1", "B1" } });
objData["B1"].Add("motorb2", "B2");
objData["B1"].Add("motorb3", "B3");
//Read data from nested dictionary
foreach (var outerDict in objData)
{
var innerDict = outerDict.Value;
foreach (var innerDictValue in innerDict)
{
Console.WriteLine(outerDict.Key + " " + innerDictValue.Key + " " + innerDictValue.Value);
}
}