GenericDictionary Sample

Back to summary

Source

using System.Collections.Generic;

namespace XmlSerializersTest.Samples
{
    [Title("Generic dictionary")]
    public class GenericDictionary
    {
        public Dictionary<int, string> Things { get; set; }
    }
}

WCF-ref Serializer

<GenericDictionary xmlns:i="http://www.w3.org/2001/XMLSchema-instance" z:Id="1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/XmlSerializersTest.Samples">
  <Things xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" z:Id="2" z:Size="2">
    <d2p1:KeyValueOfintstring>
      <d2p1:Key>1</d2p1:Key>
      <d2p1:Value z:Id="3">one</d2p1:Value>
    </d2p1:KeyValueOfintstring>
    <d2p1:KeyValueOfintstring>
      <d2p1:Key>2</d2p1:Key>
      <d2p1:Value z:Id="4">two</d2p1:Value>
    </d2p1:KeyValueOfintstring>
  </Things>
</GenericDictionary>