title: How to access a nested Dictionary<> objects in a foreach loop
body: <p>I have a nested Dictionary structure like this:</p>
  
  <pre><code>Dictionary&lt;string, Dictionary&lt;string, string&gt;&gt; dict;
  </code></pre>
  
  <p>I'm trying to access the elements using two foreach loops but the compiler won't let me use the following as the loop variable for my inner loop:</p>
  
  <pre><code>Dictionary&lt;string, string&gt;
  </code></pre>
  
  <p>This is what I have:</p>
  
  <pre><code>foreach (string key in dict.Keys) {
      foreach (Dictionary&lt;string, string&gt; innerDict in dict[key]) {
          // ...
      }
  }
  </code></pre>
  
  <p>The compiler says:</p>
  
  <pre><code>Cannot convert type 'System.Collections.Generic.KeyValuePair&lt;string,string&gt;'
   to 'System.Collections.Generic.Dictionary&lt;string,string&gt;'
  </code></pre>
  
  <p>I can use KeyValuePair&lt;string,string> in the inner loop, but I would like to access the dictionary object itself as a whole (so that I can do something like this: if (dict.ContainsKey(innerDict)) { ... })</p>