I have class with a List
member. If I want to clone an instance of this class, do I need a deep copy or the MemberwiseClone()
shallow co
If you have List
then doing this:
List
foreach(int i in originalList)
newList.Add(i);
will get you a cloned list.
However, if you tried what I did above with a List generic on some reference type, then you would not succeed. After altering one of the objects in your list, you would see the altered version whether referencing it from the original list or the new list.