<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Shawson&#039;s Code Blog &#187; array</title>
	<atom:link href="http://www.shawson.co.uk/codeblog/tag/array/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shawson.co.uk/codeblog</link>
	<description>development notes for my failing memory</description>
	<lastBuildDate>Mon, 06 Sep 2010 19:43:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Deep Copy Array/ Collection/ etc using serialization</title>
		<link>http://www.shawson.co.uk/codeblog/deep-copy-array-collection-etc/</link>
		<comments>http://www.shawson.co.uk/codeblog/deep-copy-array-collection-etc/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 10:28:41 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#.net]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[collection]]></category>
		<category><![CDATA[deep copy]]></category>
		<category><![CDATA[serialise]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=358</guid>
		<description><![CDATA[A useful snippet of code I used in a web services project a while ago which i just stumbled back across recently- allows you to make a deep copy of an array, where you would normally get a shallow copy, stopping you from manipulating it independently from the source.  This gives you a completely [...]


Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/a-complete-list-of-net-serializers-in-3-5/' rel='bookmark' title='Permanent Link: A complete list of .NET Serializers in 3.5'>A complete list of .NET Serializers in 3.5</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/making-your-wcf-service-compatible-with-legacy-net-1-1-applications/' rel='bookmark' title='Permanent Link: Making your WCF Service compatible with legacy .net 1.1 applications'>Making your WCF Service compatible with legacy .net 1.1 applications</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/aspnet-role-membership-providers-under-iis7-doesnt-work/' rel='bookmark' title='Permanent Link: ASP.Net Role &#038; Membership Providers (Under IIS7) &#8211; DOESN&#8217;T Work!'>ASP.Net Role &#038; Membership Providers (Under IIS7) &#8211; DOESN&#8217;T Work!</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>A useful snippet of code I used in a web services project a while ago which i just stumbled back across recently- allows you to make a deep copy of an array, where you would normally get a shallow copy, stopping you from manipulating it independently from the source.  This gives you a completely fresh and separate copy.  The original is serialised to a memory, then a new instance created from the serialised representation (so obviously if it&#8217;s an array of custom objects, those objects will need to be marked serializable)</p>
<pre class="brush: csharp">
OrderItem[] order_items_clone;
using( MemoryStream ms = new MemoryStream())
{
	System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
	formatter.Serialize(ms,order_items);
	ms.Seek(0 , SeekOrigin.Begin);
	order_items_clone = (OrderItem[])formatter.Deserialize(ms);
}
</pre>


<p>Related posts:<ul><li><a href='http://www.shawson.co.uk/codeblog/a-complete-list-of-net-serializers-in-3-5/' rel='bookmark' title='Permanent Link: A complete list of .NET Serializers in 3.5'>A complete list of .NET Serializers in 3.5</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/making-your-wcf-service-compatible-with-legacy-net-1-1-applications/' rel='bookmark' title='Permanent Link: Making your WCF Service compatible with legacy .net 1.1 applications'>Making your WCF Service compatible with legacy .net 1.1 applications</a></li>
<li><a href='http://www.shawson.co.uk/codeblog/aspnet-role-membership-providers-under-iis7-doesnt-work/' rel='bookmark' title='Permanent Link: ASP.Net Role &#038; Membership Providers (Under IIS7) &#8211; DOESN&#8217;T Work!'>ASP.Net Role &#038; Membership Providers (Under IIS7) &#8211; DOESN&#8217;T Work!</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.shawson.co.uk/codeblog/deep-copy-array-collection-etc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
