Home
Manage Your Code
Snippet: XML Serializable Generic Dictionary (C#)
Title: XML Serializable Generic Dictionary Language: C#
Description: For some reason, the generic Dictionary in .net 2.0 is not XML serializable. The following code snippet is a xml serializable generic dictionary. The dictionary is serialzable by implementing the IXmlSerializable interface Views: 441
Author: Frode Hansen Date Added: 1/26/2007
Copy Code  
1
2
3    using System;
4
5    using System.Collections.Generic;
6
7    using System.Text;
8
9    using System.Xml.Serialization;
10
11 
12
13    [XmlRoot("dictionary")]
14
15    public class SerializableDictionary<TKey, TValue>
16
17        : Dictionary<TKey, TValue>, IXmlSerializable
18
19    {
20        #region IXmlSerializable Members   ...        #endregion
137
138    }
139
140
Usage
Brukes istedenfor standard .NET Dictionary.
Notes
http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx