title: How do I enumerate a static dictionary contained in a static class from asp.net ( aspx) page
body: <p>I don't understand how to loop over a static dictionary contained in a static class from my aspx page. I have this for the static class</p>
  
  <pre><code>public static class ErrorCode  
  
  {
      public static IDictionary&lt;int, string&gt; ErrorCodeDic;
  
      static ErrorCode()
      {
          ErrorCodeDic = new Dictionary&lt;int, string&gt;()
          { 
              {1, "a problem"},
              {2, "b problem"}
          };
      }
  }
  </code></pre>
  
  <p>MORE SPECIFIC 
  I can get it to work by spelling it out like this in the aspx part</p>
  
  <pre><code>foreach( System.Collections.generic.KeyValuePair&lt;int, string&gt; kvp in MyLibrary.Dictionaries.ErrorCode.ErrorCodeDic) 
  </code></pre>
  
  <p>But I thought I could shorthand it by declaring variables in the code behind?</p>
  
  <pre><code>Public KeyValuePair&lt;int, string&gt; error;
  Public ErrorCode.ErrorCodeDic ErrorCodes; OR
  Public ErrorCode.ErrorCodeDic ErrorCodes = ErrorCode.ErrorCodeDic; "
  </code></pre>
  
  <p>I get build errors "The type name 'ErrorCodeDic' does not exist in the type ErrorCode.</p>
  
  <p>And then in the aspx page use </p>
  
  <pre><code>foreach( error in ErrorCodes)
  </code></pre>