title: C# inherit from Dictionary, iterate over KeyValuePairs
body: <p>I have a class that inherits from <code>Dictionary&lt;string, string&gt;</code>.  Within an instance method, I want to iterate over all <code>KeyValuePair&lt;string, string&gt;</code>'s.  I've tried doing the following:</p>
  
  <pre><code>foreach (KeyValuePair&lt;string, string&gt; pair in base)
  </code></pre>
  
  <p>But this fails with the following error:</p>
  
  <blockquote>
    <p>Use of keyword 'base' is not valid in this context</p>
  </blockquote>
  
  <p>How can I iterate over the <code>KeyValuePair&lt;string, string&gt;</code>'s in an instance method in a class that derives from <code>Dictionary&lt;string, string&gt;</code>?</p>
  
  <p><strong>Edit:</strong>  I found I can do the following:</p>
  
  <pre><code>var enumerator = base.GetEnumerator();
  while (enumerator.MoveNext())
  {
      KeyValuePair&lt;string, string&gt; pair = enumerator.Current;
  }
  </code></pre>
  
  <p>However, I would still like to know if there's a way to do this via a <code>foreach</code> loop.</p>
  
  <p><strong>Edit:</strong>  thanks for the advice about not inheriting from <code>Dictionary&lt;string, string&gt;</code>.  I'm instead implementing <code>System.Collections.IEnumerable, ICollection&lt;KeyValuePair&lt;string, string&gt;&gt;, IEnumerable&lt;KeyValuePair&lt;string, string&gt;&gt;, IDictionary&lt;string, string&gt;</code>.</p>