Accessing private Dictionary
<p>We have a class with a dictionary that's public:  </p>

<pre><code>public class SomethingWithADictionary {
    public Dictionary&lt;string, Instance&gt; Instances { get; set; } 
}
</code></pre>

<p>Currently we access this dictionary directly, like this:</p>

<pre><code>Instance inst = a.Instances["key"];
</code></pre>

<p>We want to make the dictionary private, but have a public way to get to the dictionary elements using the same indexer syntax. The reason is, if the instance is not in the dictionary, we'd like to take some action instead of just throwing an error. </p>

<p>How do you do that?</p>
