title: How can I initialize a global nested Dictionary globally?
body: <p>I have my Dictionary declared like this:</p>
  
  <pre><code>private static Dictionary&lt;string, Dictionary&lt;string, string&gt;&gt; myDictionary;
  </code></pre>
  
  <p>I want to initialize it globally.  The closest I have come initializes the outer Dictionary, but still leaves me with a null reference to the inner Dictionary:</p>
  
  <pre><code>private static Dictionary&lt;string, Dictionary&lt;string, string&gt;&gt; myDictionary
   = new Dictionary&lt;string, Dictionary&lt;string, string&gt;&gt;();
  </code></pre>
  
  <p>I need to avoid initializing it in a method, because I don't want to force the user to call a method before being able to use my class.  The user only has access to static methods.  I could create a singleton when they call one of the methods, but that's dirty.</p>
  
  <p>How can I declare both dictionaries globally?  Something along the lines of one of these (although neither compile):</p>
  
  <pre><code>private static Dictionary&lt;string, Dictionary&lt;string, string&gt;&gt; myDictionary
   = new Dictionary&lt;string, new Dictionary&lt;string, string&gt;&gt;();
  </code></pre>
  
  <p>or</p>
  
  <pre><code>private static Dictionary&lt;string, string&gt; inner = new Dictionary&lt;string, string&gt;();
  private static Dictionary&lt;string, Dictionary&lt;string, string&gt;&gt; myDictionary
   = new Dictionary&lt;string, inner&gt;();
  </code></pre>