<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Serializing an IDictionary object</title>
	<atom:link href="http://www.mattberther.com/2004/06/14/serializing-an-idictionary-object/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattberther.com/2004/06/14/serializing-an-idictionary-object/</link>
	<description>Agile Manager and Occasional Code Monkey</description>
	<lastBuildDate>Sun, 21 Feb 2010 22:01:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Martin</title>
		<link>http://www.mattberther.com/2004/06/14/serializing-an-idictionary-object/comment-page-1/#comment-166555</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Mon, 21 Dec 2009 13:21:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattberther.com/blog/?p=487#comment-166555</guid>
		<description>Putting this in your class containing the hashtable works when serializing a hierarchy in which your hashtable is just one of many elemtent.

        public DictionarySerializer ParametersXML
        {
            get { return new DictionarySerializer(parameters); }
            set { parameters = (Hashtable) ((DictionarySerializer)value).Dictionary; }
        }


In order for this to work you need to make the second constructor public and add a Property like so:

        [XmlIgnoreAttribute]
        public IDictionary Dictionary
        {
            get { return dictionary; }
            set { dictionary = value; }
        }</description>
		<content:encoded><![CDATA[<p>Putting this in your class containing the hashtable works when serializing a hierarchy in which your hashtable is just one of many elemtent.</p>
<p>        public DictionarySerializer ParametersXML<br />
        {<br />
            get { return new DictionarySerializer(parameters); }<br />
            set { parameters = (Hashtable) ((DictionarySerializer)value).Dictionary; }<br />
        }</p>
<p>In order for this to work you need to make the second constructor public and add a Property like so:</p>
<p>        [XmlIgnoreAttribute]<br />
        public IDictionary Dictionary<br />
        {<br />
            get { return dictionary; }<br />
            set { dictionary = value; }<br />
        }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pavel Golodoniuc</title>
		<link>http://www.mattberther.com/2004/06/14/serializing-an-idictionary-object/comment-page-1/#comment-166516</link>
		<dc:creator>Pavel Golodoniuc</dc:creator>
		<pubDate>Sat, 15 Aug 2009 09:30:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattberther.com/blog/?p=487#comment-166516</guid>
		<description>Thank you Matt for the great idea you have implemented here. It has saved me some time reinventing the wheel. I have slightly improved your DictionarySerializer class so that now it also allows to serialize contained objects as XML providing that they implement IXmlSerializable interface. I thought that it might be worth sharing it with others.


public class DictionarySerializer : IXmlSerializable
{
	private IDictionary _dictionary = null;

	private DictionarySerializer()
	{
		_dictionary = new Hashtable();
	}

	private DictionarySerializer(IDictionary dictionary)
	{
		_dictionary = dictionary;
	}

	public static void Serialize(IDictionary dictionary, Stream stream)
	{
		DictionarySerializer ds = new DictionarySerializer(dictionary);
		XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer));
		xs.Serialize(stream, ds);
	}

	public static void Serialize(IDictionary dictionary, TextWriter textWriter)
	{
		DictionarySerializer ds = new DictionarySerializer(dictionary);
		XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer));
		xs.Serialize(textWriter, ds);
	}

	public static void Serialize(IDictionary dictionary, XmlWriter xmlWriter)
	{
		DictionarySerializer ds = new DictionarySerializer(dictionary);
		XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer));
		xs.Serialize(xmlWriter, ds);
	}

	public static IDictionary Deserialize(Stream stream)
	{
		XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer));
		DictionarySerializer ds = (DictionarySerializer)xs.Deserialize(stream);
		return ds._dictionary;
	}

	public static IDictionary Deserialize(TextReader textReader)
	{
		XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer));
		DictionarySerializer ds = (DictionarySerializer)xs.Deserialize(textReader);
		return ds._dictionary;
	}

	public static IDictionary Deserialize(XmlReader xmlReader)
	{
		XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer));
		DictionarySerializer ds = (DictionarySerializer)xs.Deserialize(xmlReader);
		return ds._dictionary;
	}

	#region IXmlSerializable Members

	XmlSchema IXmlSerializable.GetSchema()
	{
		return null;
	}

	void IXmlSerializable.ReadXml(XmlReader reader)
	{
		reader.Read();
		reader.ReadStartElement(&quot;dictionary&quot;);
		while (reader.NodeType != XmlNodeType.EndElement)
		{
			reader.ReadStartElement(&quot;item&quot;);
			string key = reader.ReadElementString(&quot;key&quot;);

			// Read value
			string sType = reader.GetAttribute(&quot;type&quot;);
			if (sType == null)
				_dictionary.Add(key, reader.ReadElementString(&quot;value&quot;));
			else
			{
				reader.ReadStartElement(&quot;value&quot;);
				Type valuetype = Type.GetType(sType);
				XmlSerializer xs = new XmlSerializer(valuetype);
				_dictionary.Add(key, xs.Deserialize(reader));
				reader.ReadEndElement();
				reader.ReadEndElement();
			}

			reader.ReadEndElement();
			reader.MoveToContent();
		}
		reader.ReadEndElement();
	}

	void IXmlSerializable.WriteXml(XmlWriter writer)
	{
		writer.WriteStartElement(&quot;dictionary&quot;);
		foreach (object key in _dictionary.Keys)
		{
			object value = _dictionary[key];
			writer.WriteStartElement(&quot;item&quot;);
			writer.WriteElementString(&quot;key&quot;, key.ToString());

			// Serialize value
			Type valuetype = value.GetType();
			if (valuetype.GetInterface(&quot;System.Xml.Serialization.IXmlSerializable&quot;) == null)
				writer.WriteElementString(&quot;value&quot;, value.ToString());
			else
			{
				XmlSerializer xs = new XmlSerializer(valuetype);
				writer.WriteStartElement(&quot;value&quot;);
				writer.WriteAttributeString(&quot;type&quot;, valuetype.FullName);
				xs.Serialize(writer, value);
				writer.WriteEndElement();
			}

			writer.WriteEndElement();
		}
		writer.WriteEndElement();
	}

	#endregion
}</description>
		<content:encoded><![CDATA[<p>Thank you Matt for the great idea you have implemented here. It has saved me some time reinventing the wheel. I have slightly improved your DictionarySerializer class so that now it also allows to serialize contained objects as XML providing that they implement IXmlSerializable interface. I thought that it might be worth sharing it with others.</p>
<p>public class DictionarySerializer : IXmlSerializable<br />
{<br />
	private IDictionary _dictionary = null;</p>
<p>	private DictionarySerializer()<br />
	{<br />
		_dictionary = new Hashtable();<br />
	}</p>
<p>	private DictionarySerializer(IDictionary dictionary)<br />
	{<br />
		_dictionary = dictionary;<br />
	}</p>
<p>	public static void Serialize(IDictionary dictionary, Stream stream)<br />
	{<br />
		DictionarySerializer ds = new DictionarySerializer(dictionary);<br />
		XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer));<br />
		xs.Serialize(stream, ds);<br />
	}</p>
<p>	public static void Serialize(IDictionary dictionary, TextWriter textWriter)<br />
	{<br />
		DictionarySerializer ds = new DictionarySerializer(dictionary);<br />
		XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer));<br />
		xs.Serialize(textWriter, ds);<br />
	}</p>
<p>	public static void Serialize(IDictionary dictionary, XmlWriter xmlWriter)<br />
	{<br />
		DictionarySerializer ds = new DictionarySerializer(dictionary);<br />
		XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer));<br />
		xs.Serialize(xmlWriter, ds);<br />
	}</p>
<p>	public static IDictionary Deserialize(Stream stream)<br />
	{<br />
		XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer));<br />
		DictionarySerializer ds = (DictionarySerializer)xs.Deserialize(stream);<br />
		return ds._dictionary;<br />
	}</p>
<p>	public static IDictionary Deserialize(TextReader textReader)<br />
	{<br />
		XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer));<br />
		DictionarySerializer ds = (DictionarySerializer)xs.Deserialize(textReader);<br />
		return ds._dictionary;<br />
	}</p>
<p>	public static IDictionary Deserialize(XmlReader xmlReader)<br />
	{<br />
		XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer));<br />
		DictionarySerializer ds = (DictionarySerializer)xs.Deserialize(xmlReader);<br />
		return ds._dictionary;<br />
	}</p>
<p>	#region IXmlSerializable Members</p>
<p>	XmlSchema IXmlSerializable.GetSchema()<br />
	{<br />
		return null;<br />
	}</p>
<p>	void IXmlSerializable.ReadXml(XmlReader reader)<br />
	{<br />
		reader.Read();<br />
		reader.ReadStartElement(&#8221;dictionary&#8221;);<br />
		while (reader.NodeType != XmlNodeType.EndElement)<br />
		{<br />
			reader.ReadStartElement(&#8221;item&#8221;);<br />
			string key = reader.ReadElementString(&#8221;key&#8221;);</p>
<p>			// Read value<br />
			string sType = reader.GetAttribute(&#8221;type&#8221;);<br />
			if (sType == null)<br />
				_dictionary.Add(key, reader.ReadElementString(&#8221;value&#8221;));<br />
			else<br />
			{<br />
				reader.ReadStartElement(&#8221;value&#8221;);<br />
				Type valuetype = Type.GetType(sType);<br />
				XmlSerializer xs = new XmlSerializer(valuetype);<br />
				_dictionary.Add(key, xs.Deserialize(reader));<br />
				reader.ReadEndElement();<br />
				reader.ReadEndElement();<br />
			}</p>
<p>			reader.ReadEndElement();<br />
			reader.MoveToContent();<br />
		}<br />
		reader.ReadEndElement();<br />
	}</p>
<p>	void IXmlSerializable.WriteXml(XmlWriter writer)<br />
	{<br />
		writer.WriteStartElement(&#8221;dictionary&#8221;);<br />
		foreach (object key in _dictionary.Keys)<br />
		{<br />
			object value = _dictionary[key];<br />
			writer.WriteStartElement(&#8221;item&#8221;);<br />
			writer.WriteElementString(&#8221;key&#8221;, key.ToString());</p>
<p>			// Serialize value<br />
			Type valuetype = value.GetType();<br />
			if (valuetype.GetInterface(&#8221;System.Xml.Serialization.IXmlSerializable&#8221;) == null)<br />
				writer.WriteElementString(&#8221;value&#8221;, value.ToString());<br />
			else<br />
			{<br />
				XmlSerializer xs = new XmlSerializer(valuetype);<br />
				writer.WriteStartElement(&#8221;value&#8221;);<br />
				writer.WriteAttributeString(&#8221;type&#8221;, valuetype.FullName);<br />
				xs.Serialize(writer, value);<br />
				writer.WriteEndElement();<br />
			}</p>
<p>			writer.WriteEndElement();<br />
		}<br />
		writer.WriteEndElement();<br />
	}</p>
<p>	#endregion<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron</title>
		<link>http://www.mattberther.com/2004/06/14/serializing-an-idictionary-object/comment-page-1/#comment-166199</link>
		<dc:creator>Aaron</dc:creator>
		<pubDate>Tue, 16 Dec 2008 12:35:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattberther.com/blog/?p=487#comment-166199</guid>
		<description>Thanks for providing the code Matt.

I find the IDictionary objects like HashTables and SortedLists to be incredibly useful so being able to serialise them is a must for me.</description>
		<content:encoded><![CDATA[<p>Thanks for providing the code Matt.</p>
<p>I find the IDictionary objects like HashTables and SortedLists to be incredibly useful so being able to serialise them is a must for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tyler</title>
		<link>http://www.mattberther.com/2004/06/14/serializing-an-idictionary-object/comment-page-1/#comment-166086</link>
		<dc:creator>Tyler</dc:creator>
		<pubDate>Fri, 31 Oct 2008 16:41:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattberther.com/blog/?p=487#comment-166086</guid>
		<description>Answered my own question. I just had to set the class to public, and excuse my stupidity, but that&#039;s never something I&#039;ve had to do so I didn&#039;t even know it was possible!!</description>
		<content:encoded><![CDATA[<p>Answered my own question. I just had to set the class to public, and excuse my stupidity, but that&#8217;s never something I&#8217;ve had to do so I didn&#8217;t even know it was possible!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tyler</title>
		<link>http://www.mattberther.com/2004/06/14/serializing-an-idictionary-object/comment-page-1/#comment-166085</link>
		<dc:creator>Tyler</dc:creator>
		<pubDate>Fri, 31 Oct 2008 02:17:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattberther.com/blog/?p=487#comment-166085</guid>
		<description>I tried to implement this class, but at the line &quot;XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer))&quot; in the first function I call, Serialization, I get the run time error: &quot;DictionarySerializer is inaccessible due to its protection level.&quot; I&#039;ve tried to set a bunch of things to public. I am calling the function from another class like: DictionarySerializer.Serialize(ht,fs), where hs and fs are a Hashtable and FileStream respectively.

Any ideas why?</description>
		<content:encoded><![CDATA[<p>I tried to implement this class, but at the line &#8220;XmlSerializer xs = new XmlSerializer(typeof(DictionarySerializer))&#8221; in the first function I call, Serialization, I get the run time error: &#8220;DictionarySerializer is inaccessible due to its protection level.&#8221; I&#8217;ve tried to set a bunch of things to public. I am calling the function from another class like: DictionarySerializer.Serialize(ht,fs), where hs and fs are a Hashtable and FileStream respectively.</p>
<p>Any ideas why?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deployment Zone &#187; IDictionary&#60;TKey,TValue&#62;, IXmlSerializable, and lambdas</title>
		<link>http://www.mattberther.com/2004/06/14/serializing-an-idictionary-object/comment-page-1/#comment-166033</link>
		<dc:creator>Deployment Zone &#187; IDictionary&#60;TKey,TValue&#62;, IXmlSerializable, and lambdas</dc:creator>
		<pubDate>Fri, 19 Sep 2008 17:29:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattberther.com/blog/?p=487#comment-166033</guid>
		<description>[...] originally used some somewhat dated code I found on Matt Berther&#039;s blog and while it worked, it gave me the nodey version I didn&#039;t care much [...]</description>
		<content:encoded><![CDATA[<p>[...] originally used some somewhat dated code I found on Matt Berther&#8217;s blog and while it worked, it gave me the nodey version I didn&#8217;t care much [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pepz</title>
		<link>http://www.mattberther.com/2004/06/14/serializing-an-idictionary-object/comment-page-1/#comment-165884</link>
		<dc:creator>pepz</dc:creator>
		<pubDate>Sun, 22 Jun 2008 00:49:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattberther.com/blog/?p=487#comment-165884</guid>
		<description>I think the function &#039;ReadXml&#039; needs an extra function call to &#039;reader.ReadEndElement()&#039; to fully close out the working node.  This should allow it to work within larger object graphs as well.</description>
		<content:encoded><![CDATA[<p>I think the function &#8216;ReadXml&#8217; needs an extra function call to &#8216;reader.ReadEndElement()&#8217; to fully close out the working node.  This should allow it to work within larger object graphs as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nikhil Shah</title>
		<link>http://www.mattberther.com/2004/06/14/serializing-an-idictionary-object/comment-page-1/#comment-165587</link>
		<dc:creator>Nikhil Shah</dc:creator>
		<pubDate>Fri, 21 Mar 2008 07:26:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattberther.com/blog/?p=487#comment-165587</guid>
		<description>This works very well,
gooood work , 
data gets serialized successfully, 
but does not gets deserialize !!!
my problem is smwht like this, I have Four  hashtable that stores the key n value pair,
on Form I have 4 combobox n 4 respective textbox ,
I wnt to populate the Key in combobx n Its RESPECTIVE value in textbox
on the selectedindex event of the combx, I where I write a code
I gets an error, tht there is a problem with XML document !!!
this XMl doc is well-formed, No-bugs thr..
this means tht the data is nt deserializing ...

If you get this, plz help me out m stuck in this prblm since last 2 days :(</description>
		<content:encoded><![CDATA[<p>This works very well,<br />
gooood work ,<br />
data gets serialized successfully,<br />
but does not gets deserialize !!!<br />
my problem is smwht like this, I have Four  hashtable that stores the key n value pair,<br />
on Form I have 4 combobox n 4 respective textbox ,<br />
I wnt to populate the Key in combobx n Its RESPECTIVE value in textbox<br />
on the selectedindex event of the combx, I where I write a code<br />
I gets an error, tht there is a problem with XML document !!!<br />
this XMl doc is well-formed, No-bugs thr..<br />
this means tht the data is nt deserializing &#8230;</p>
<p>If you get this, plz help me out m stuck in this prblm since last 2 days :(</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://www.mattberther.com/2004/06/14/serializing-an-idictionary-object/comment-page-1/#comment-155512</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Wed, 10 Oct 2007 16:16:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattberther.com/blog/?p=487#comment-155512</guid>
		<description>Hmm, that comment has mangled some of the XML tags that were in the code, the method won&#039;t work as it is shown on this page</description>
		<content:encoded><![CDATA[<p>Hmm, that comment has mangled some of the XML tags that were in the code, the method won&#8217;t work as it is shown on this page</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://www.mattberther.com/2004/06/14/serializing-an-idictionary-object/comment-page-1/#comment-155511</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Wed, 10 Oct 2007 16:15:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattberther.com/blog/?p=487#comment-155511</guid>
		<description>Everything being serialized as a string, and the non-recursive nature of the serialization make this kind of useless. I&#039;ve ended up writing a couple of helper methods that will serialize and deserialize nested IDictionary objects too.

&lt;code&gt;
	public static StringBuilder Serialize(StringBuilder sb, object obj)
        {
            if (typeof(IDictionary).IsAssignableFrom(obj.GetType()))
            {
                sb.Append(&quot;&quot;);
                foreach (object key in ((IDictionary)obj).Keys)
                {
                    sb.Append(&quot;&quot;);
                    Serialize(sb, ((IDictionary)obj)[key]);
                    sb.Append(&quot;&quot;);
                }
                sb.Append(&quot;&quot;);
            }
            else
            {
                StringWriter sw = new StringWriter(sb);
                XmlSerializer xs = new XmlSerializer(obj.GetType());                
                sb.Append(&quot;&quot;);
                //need a bodge in here to deal with unnamed datatables
                xs.Serialize(sw, obj);
                sb.Append(&quot;&quot;);
            }

            return sb.Replace(&quot;&quot;, &quot;&quot;);
        }

        public static object Deserialize(string s)
        {
            Object obj = new Object();

            XmlDocument xml = new XmlDocument();
            xml.LoadXml(s);

            XmlNode node = xml.ChildNodes[0];
            if (node.Name.Contains(&quot;IDictionary_&quot;))
            {
                obj = Activator.CreateInstance(Type.GetType(XmlConvert.DecodeName(node.Name.Replace(&quot;IDictionary_&quot;, &quot;&quot;))));
                foreach (XmlNode child in node.ChildNodes)
                    ((IDictionary)obj).Add(child.Name.Replace(&quot;Key_&quot;, &quot;&quot;), Deserialize(child.InnerXml));
            }
            else if (node.Name.Contains(&quot;Type_&quot;))
            {
                StringReader sr = new StringReader(&quot;&quot; + node.InnerXml);
                XmlSerializer xs = new XmlSerializer(Type.GetType(XmlConvert.DecodeName(node.Name.Replace(&quot;Type_&quot;, &quot;&quot;))));
                obj = xs.Deserialize(sr);
            }

            return obj;
        }
&lt;/code&gt;

Use it like this:
	&lt;code&gt;
Hashtable ht1 = new Hashtable();
        ht1[&quot;1&quot;] = 1;
        ht1[&quot;2&quot;] = 2;

        Hashtable ht2 = new Hashtable();
        ht2[&quot;a&quot;] = &quot;a&quot;;
        ht2[&quot;b&quot;] = &quot;b&quot;;

        ht1[&quot;3&quot;] = ht2;

        Serialize(new StringBuilder(), ht1);
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Everything being serialized as a string, and the non-recursive nature of the serialization make this kind of useless. I&#8217;ve ended up writing a couple of helper methods that will serialize and deserialize nested IDictionary objects too.</p>
<p><code><br />
	public static StringBuilder Serialize(StringBuilder sb, object obj)<br />
        {<br />
            if (typeof(IDictionary).IsAssignableFrom(obj.GetType()))<br />
            {<br />
                sb.Append("");<br />
                foreach (object key in ((IDictionary)obj).Keys)<br />
                {<br />
                    sb.Append("");<br />
                    Serialize(sb, ((IDictionary)obj)[key]);<br />
                    sb.Append("");<br />
                }<br />
                sb.Append("");<br />
            }<br />
            else<br />
            {<br />
                StringWriter sw = new StringWriter(sb);<br />
                XmlSerializer xs = new XmlSerializer(obj.GetType());<br />
                sb.Append("");<br />
                //need a bodge in here to deal with unnamed datatables<br />
                xs.Serialize(sw, obj);<br />
                sb.Append("");<br />
            }</p>
<p>            return sb.Replace("", "");<br />
        }</p>
<p>        public static object Deserialize(string s)<br />
        {<br />
            Object obj = new Object();</p>
<p>            XmlDocument xml = new XmlDocument();<br />
            xml.LoadXml(s);</p>
<p>            XmlNode node = xml.ChildNodes[0];<br />
            if (node.Name.Contains("IDictionary_"))<br />
            {<br />
                obj = Activator.CreateInstance(Type.GetType(XmlConvert.DecodeName(node.Name.Replace("IDictionary_", ""))));<br />
                foreach (XmlNode child in node.ChildNodes)<br />
                    ((IDictionary)obj).Add(child.Name.Replace("Key_", ""), Deserialize(child.InnerXml));<br />
            }<br />
            else if (node.Name.Contains("Type_"))<br />
            {<br />
                StringReader sr = new StringReader("" + node.InnerXml);<br />
                XmlSerializer xs = new XmlSerializer(Type.GetType(XmlConvert.DecodeName(node.Name.Replace("Type_", ""))));<br />
                obj = xs.Deserialize(sr);<br />
            }</p>
<p>            return obj;<br />
        }<br />
</code></p>
<p>Use it like this:<br />
	<code><br />
Hashtable ht1 = new Hashtable();<br />
        ht1["1"] = 1;<br />
        ht1["2"] = 2;</p>
<p>        Hashtable ht2 = new Hashtable();<br />
        ht2["a"] = "a";<br />
        ht2["b"] = "b";</p>
<p>        ht1["3"] = ht2;</p>
<p>        Serialize(new StringBuilder(), ht1);<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
