Here's an easy way of cloning an object (deep copy):
MemoryStream memstream = new MemoryStream();
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(memstream, obj);
memstream.Seek(0, SeekOrigin.Begin);
T clone = (T)formatter.Deserialize(memstream);
memstream.Close();
return clone;
}
The requirement is of course that the object is serializable and marked with the [Serializable] attribute.
[powered by WordPress.]
jour·nal n. A personal record of occurrences, experiences, and reflections kept on a regular basis; a diary.
36 queries. 0.352 seconds