title: Lazy dictionary properties in C#
body: <p>I have a class with a property that's a Dictionary:</p>
  <pre><code>public class Entity 
  {
      public Dictionary&lt;string, string&gt; Name { get; set; }
  }
  </code></pre>
  <p>I would like switch this property to use lazy initializtion. I tried the following:</p>
  <pre><code>public class Entity 
  {
      private Lazy&lt;Dictionary&lt;string, string&gt;&gt; name = new Lazy&lt;Dictionary&lt;string, string&gt;&gt;(() =&gt; new Dictionary&lt;string, string&gt;(StringComparer.OrdinalIgnoreCase));
      public Dictionary&lt;string, string&gt; Name
      {
          get =&gt; name;
          set =&gt; name = value;
      }
  }
  </code></pre>
  <p>This is of course an error, as Name and name have different types. For the life of me though, I can't figure out how to specify this correctly. All I really want is to have Name remain null until I access it, then create it on the first read or write.</p>