answersLogoWhite

0

How would one do a deep copy in NET?

User Avatar

Anonymous

16y ago
Updated: 8/16/2019

One method I use often is to mark my class with the [Serializable] attribute, then serialize the object to a memory stream. Then, take the memstream and deserialize to a new object instance, and return the new object. The other more clumsy way is to have a method that copies the values from each individual member from the old to the new, making sure that any reference types also perform a deep copy.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

What is difference between Deep copy and shallow copy in iphone?

Shallow copy is duplicate little as possible. because of it copy one object to another object. it copy only structure not elements . Deep copy means Duplicate everything. it will be copy structure as well as elements; e.g :- char A*={'a','b','c'}; char B*={'x','y','z'}; B=A;


What is shallow copy in Java?

A shallow copy in Java refers to the copying of object references from one collection to another. In contrast, a deep copy in Java refers to the copying of actual object data from one collection to another. // shallow copy Object[] original = {new Object(), new Object(), new Object()}; Object[] copy = new Object[original.length]; for(int i = 0; i < original.length; ++i) copy[i] = original[i]; // deep copy Object[] original = {new Object(), new Object(), new Object()}; Object[] copy = new Object[original.length]; for(int i = 0; i < original.length; ++i) // this would not compile in this case because Object does not have a publicly // accessible clone() method. if you were to use this, make sure that the type // has an accessible clone() method copy[i] = original[i].clone();


How would someone find a copy of an actual lawsuit?

The original is filed with the clerk in the court where the suit is being litigated. One would get a copy by going to the clerks' office and getting one.


What is copy paste?

I got one answer as I searched the net. After reading this, you may please give other related things. See it here http://hubpages.com/hub/10-reasons-you-should-buy-copy-paste-systems


I would like to get a free copy of my business license where do i go to get one?

They should have sent you one when you got it. you can not get a free copy from them after that but have to pay for copies to be sent.


How would someone make a soccer net?

To make a soccer net, one would use thick netting, industrial glue, zip ties, PVC piping, pipe elbows, and pipe tees. They would construct the net with these materials.


What is copy paste system?

I got one answer as I searched the net. After reading this, you may please give other related things. See it here http://hubpages.com/hub/10-reasons-you-should-buy-copy-paste-systems


What is the method to work out net sales from gross sales?

The easiest method that one could possibly use to determine net sales from gross sales would be to subtract the amount made total (gross) from the amount one paid for the item to sell. The left over figure would be what was made after expenses, or one's net sales. This would be basically the same as figuring out what one's net income is from their gross income on their paycheck each payday.


For what reason would one clone a DVD?

The primary reason you would clone or copy a DVD is to gift the DVD copy to a friend or family member. It could also be because you rented the DVD and you wish to have a permanent copy, however that would be illegal.


How can one get a replacement copy of a pay stub?

One can get a replacement copy of a pay stub from your employer. However for them to acquire another copy will require extra fees. These fees will either be absorbed by your employer or you would have to pay for it.


What are some scenarios where one would use a cast net?

A cast net would be used when fishing. Cast nets are usually used when one is fishing for small fish. People have been using a version of this type of net all over the world for hundreds of years.


How would one gain health net insurance?

To gain health net insurance you would have to reduce some percent from your medical, so that the proportions would be equally, and so you can use your premium.