HighTechTalks DotNet Forums  

diff b/w shaloow copy and deep copy

Dotnet Academic General Discussions microsoft.public.dotnet.academic


Discuss diff b/w shaloow copy and deep copy in the Dotnet Academic General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
sujith
 
Posts: n/a

Default diff b/w shaloow copy and deep copy - 02-20-2007 , 01:35 AM






hello can anybody explain diffrence between shaloow copy and deep copy in c#

Reply With Quote
  #2  
Old   
pvdg42
 
Posts: n/a

Default Re: diff b/w shaloow copy and deep copy - 02-20-2007 , 10:09 AM







"sujith" <sujith (AT) discussions (DOT) microsoft.com> wrote

Quote:
hello can anybody explain diffrence between shaloow copy and deep copy in
c#
This applies, not just to C#, but to any language that employs "reference
types".

When copying an object, a shallow copy makes copies of the contents of
fields as defined in the class definition. If one or more of the fields is a
reference type (holds the address where the actual data is stored), then it
is the address that is copied. You end up with multiple references to the
same data.
When you write a method to perform a "deep copy", you don't just copy the
addresses stored in reference type fields, you retrieve the actual data and
make a copy of the data at a new location, thus making the new copied object
fully independent of the original object.


--
Peter [MVP Visual Developer]
Jack of all trades, master of none.




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.