I am trying to print results from nested dictionary
var variations_hash = new Dictionary<string, Dictionary<string, List<string>>>();
But it throws some random error
using System;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
class Program
{
static void Main()
{
var variations_hash = new Dictionary<string, Dictionary<string, List<string>>>();
var variations = new Dictionary<string, List<string>>();
variations["available"] = new List<string> { "hi" };
var stores = new[] { "s", "m", "xl", "xxl", "xxxl", "v" };
string color_trans = "blue";
foreach (var sto in stores)
{
variations_hash[sto] = variations;
}
foreach(var job in variations_hash.Key())
{
foreach (var innerDict in variations_hash[key].Select(k => k.Value))
{
Console.Write(innerDict);
}
}
Console.ReadLine();
}
}
Error:
Error CS1061 'Dictionary>>' does not contain a definition for 'Key' and no extension method 'Key' accepting a first argument of type 'Dictionary>>' could be found (are you missing a using directive or an assembly reference?)
ConsoleApplication1 c:\users\administrator\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 29Error CS0103 The name 'key' does not exist in the current context ConsoleApplication1 c:\users\administrator\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 31
Warning CS0219 The variable 'color_trans' is assigned but its value is never used
ConsoleApplication1 c:\users\administrator\documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 20
How to loop and print all the contents of nested dictionary?
.Keysinstead ofvariations_hash.Key()- PikohKey()method to do? Which variable did you expect to refer to invariations_hash[key]? - Jon Skeet