How would one do a deep copy in .NET?
ASP.NET and .NET WEB Questions and Answers
(Continued from previous question...)
How would one do a deep copy in .NET?
Answer1:
System.Array.CopyTo() - Deep copies an Array
Answer2:
How would one do a deep copy in .NET?
The First Approach.
1.Create a new instance.
2.Copy the properties from source instance to newly created instance.
[Use reflection if you want to write a common method to achive this]
The Second Approach.
1. Serialize the object and deserialize the output.
: Use binary serialization if you want private variables to be copied.
: Use xml Serialization if you dont want private variable to be copied.
(Continued on next question...)
Other Interview Questions
|