title: Adding values to a dictionary via inline initialization of its container
body: <p>I have the following <code>City</code> class. Each city object contains a dictionary which keys are language tags (let's say: "EN", "DE", "FR"...) and which values are the city names in the corresponding languages (ex: Rome / Rom etc.).</p>
  
  <pre><code>public class City:
  {
    private IDictionary&lt;string, string&gt; localizedNames = new Dictionary&lt;string, string&gt;(0);
    public virtual IDictionary&lt;string, string&gt; Names
    {
      get { return localizedNames ; }
      set { localizedNames = value; }
    }
  }
  </code></pre>
  
  <p>Most of the cities have the same names whatever the language so the <code>City</code> constructor does actually creates the English mapping:</p>
  
  <pre><code>  public City(string cityName)
    {
      this.LocalizedNames.Add("EN", cityName);
    }
  </code></pre>
  
  <p><strong>Here comes the question</strong>: is there a way to add the other values via inline initialization? </p>
  
  <p>I tried different variations of the following without semantic success (does not compile):</p>
  
  <pre><code>AllCities.Add(new City("Rome") { Names["DE"] = "Rom" };
  </code></pre>
  
  <p>I also tried creating a new Dictionary, but this obviously overwrites the "EN" parameter:</p>
  
  <pre><code>AllCities.Add(new City("Rome") { Names = new Dictionary&lt;string, string&gt;() { { "DE", "Rom" } } };
  </code></pre>
  
  <p>Anybody know if this is possible?</p>