title: c# serialize dictionary into xml file
body: <p>I'm writing an Windows Store App which involve serializing Xml file into a dictionary and vice versa. With List&lt;> and ObservableCollection&lt;>, I can do this to read from XML file:
  Word Class</p>
  
  <pre><code>public class word
  {
      [XmlElement("key")]
      public string words { get; set; }
      [XmlElement("value")]
      public string value { get; set; }
  }
  </code></pre>
  
  <p>Read Class</p>
  
  <pre><code>using System.IO;
  using Windows.Storage;
  using System.Xml.Serialization;
  using System.Collections.ObjectModel;
  
  ObservableCollection&lt;word&gt; Words = new ObservableCollection&lt;word&gt;;
      public async void Load()
          {
              StorageFolder localFolder = Windows.Storage.KnownFolders.MusicLibrary;
              StorageFile file = await localFolder.GetFileAsync("dictionary.xml");
              XmlSerializer serializer = new XmlSerializer(typeof(ObservableCollection&lt;word&gt;));
              using (Stream stream = await file.OpenStreamForReadAsync())
              {
                  ObservableCollection&lt;word&gt; list = serializer.Deserialize(stream) as ObservableCollection&lt;word&gt;;
                  foreach (var c in list)
                  {
                      Words.Add(c);
                  }
              }
          }
  </code></pre>
  
  <p>But Dictionary&lt;> has a pair of TKey and TValue, which make the code above unusable. Anyway to fix the above code to be suitable for Dictionary&lt;>? Any help is appreciate.</p>