title: How to loop through a SortedList, getting both the key and the value
body: <p>The following code loops through a list and gets the values, but how would I write a similar statement that gets both the keys and the values   </p>
  
  <pre><code>foreach (string value in list.Values)
  {
      Console.WriteLine(value);
  }
  </code></pre>
  
  <p>e.g something like this</p>
  
  <pre><code>    foreach (string value in list.Values)
  {
      Console.WriteLine(value);
          Console.WriteLine(list.key);
  }
  </code></pre>
  
  <p>code for the list is:</p>
  
  <pre><code>SortedList&lt;string, string&gt; list = new SortedList&lt;string, string&gt;();
  </code></pre>