title: Dictionary XML Serialization
body: <p>I have a class with a dictionary attribute I want to serialize. I've read that serializing a dictionary isn't directly possible so I serialize/deserialize a list I then transform to a dictionary. It works, but i would like to know if there is a proper way to do this.</p>
  
  <pre><code>[Serializable]
  public class Album
  {
  
      private List&lt;Photo&gt; photos = new List&lt;Photo&gt;();
      [XmlArray]
      public List&lt;Photo&gt; Photos
      {
          get { return photos; }
          set
          {
              photos = value;
          }
      }
  
      private Dictionary&lt;string, Photo&gt; dicoPhotos = new Dictionary&lt;string, Photo&gt;();
      [XmlIgnore]
      public Dictionary&lt;string, Photo&gt; DicoPhotos
      {
          get { return dicoPhotos; }
          set { dicoPhotos = value; }
      }
  
  
      public void fillPhotosDictionnary()
      {
          this.dicoPhotos = this.photos.ToDictionary(p =&gt; p.Nom, p =&gt; p);
      }
  }
  </code></pre>
  
  <p>I've tried to fill the dictionary in the Photo's setter, but it doesn't work and I can't figure out why.</p>