iterating through dictionary using nested foreach
<p>This is a nested dictionary pair with the below sample data.</p>

<pre><code>{"A-BC-1111/AB.CD":{"P1":"F","P2":"0.0"}
</code></pre>

<p>I am trying to iterate through it and create a collection class like this:</p>

<pre><code>public class FromDic
{
    string Name = "A-BC-1111/AB.CD";
    Attr1 = "F";
    Attr2 = "0.0";
}
</code></pre>

<p>I am trying to do nested foreach like this:</p>

<pre><code>FromDic collectiondic=new FromDic();

foreach(var Key in MyDic)
{
    collectionDic.Name=Key;

    // key on the inner loop is for “Type” and “Val”
    foreach (var key in obj.Keys)
    {
        IJsonValue val;

        if (!obj.TryGetValue(key, out val))
            continue;

        switch (key)
        {
            case "P1":
                collectionDic.Attr1 = val.GetString();
                break;
            case "P2":
                collectionDic.Attr2 = val.GetNumber().ToString();
                break;
        }
    }
}
</code></pre>

<p>But my code doesn't compile. Anything I can do to make this nested <code>foreach</code> work ?</p>
