<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>XmlSerialization snippet</title><link>http://blogs.msdn.com/jimmytr/archive/2007/03/24/xmlserialization-snippet.aspx</link><description>I keep writing this code - now I can find it on my blog in the future :-) public static class StringXmlSerializer { public static string Serialize&amp;lt;T&amp;gt;(T obj) { XmlSerializer s = new XmlSerializer( typeof (T)); StringBuilder sb = new StringBuilder</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: XmlSerialization snippet</title><link>http://blogs.msdn.com/jimmytr/archive/2007/03/24/xmlserialization-snippet.aspx#1945763</link><pubDate>Sun, 25 Mar 2007 10:54:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1945763</guid><dc:creator>ploeh</dc:creator><description>&lt;p&gt;Since you are alread calling your post a 'snippet', why not make it a real Visual Studio code snippet? It's fairly easy to do, as I've described on my own blog: &lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/ploeh/archive/2006/03/20/astypeCodeSnippet.aspx"&gt;http://blogs.msdn.com/ploeh/archive/2006/03/20/astypeCodeSnippet.aspx&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A few other things about your code snippet: StringWrite and StringReader both implement IDisposable, so you should wrap them in using statements.&lt;/p&gt;
&lt;p&gt;Besides, I'd suggest calling the class 'StringXmlSerializer' instead :)&lt;/p&gt;</description></item><item><title>re: XmlSerialization snippet</title><link>http://blogs.msdn.com/jimmytr/archive/2007/03/24/xmlserialization-snippet.aspx#1956171</link><pubDate>Tue, 27 Mar 2007 02:19:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1956171</guid><dc:creator>jimmytr</dc:creator><description>&lt;P&gt;using blocks - agree. However the local variables sw (and sr) are not really holding on to any unmanaged stuff in this case so I rely on the GC to remove my string and stringbuilder in this case. &lt;/P&gt;
&lt;P&gt;Dispose of the reader:&lt;/P&gt;
&lt;P&gt;protected override void Dispose(bool disposing)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp; this._s = null;&lt;BR&gt;&amp;nbsp;&amp;nbsp; this._pos = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp; this._length = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp; base.Dispose(disposing);&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;Dispose of writer:&lt;BR&gt;protected override void Dispose(bool disposing)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp; this._isOpen = false;&lt;BR&gt;&amp;nbsp;&amp;nbsp; base.Dispose(disposing);&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;I know it's best practice...&lt;BR&gt;If you intent to call the method often to (de-)serialize the same types caching the XmlSerializer objects will improve performance.&lt;/P&gt;
&lt;P&gt;-again-snippet not meant as a guiding example on how to write code - merely somthing I use occasionally when playing with xsd.exe and Xml Serialization.&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item><item><title>Link Listing - March 26, 2007</title><link>http://blogs.msdn.com/jimmytr/archive/2007/03/24/xmlserialization-snippet.aspx#1958919</link><pubDate>Tue, 27 Mar 2007 07:25:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1958919</guid><dc:creator>Christopher Steen</dc:creator><description>&lt;p&gt;telerik radEditor for Office SharePoint Server 2007 has been officially released! + Telerik for MCMS...&lt;/p&gt;</description></item></channel></rss>