I Have List<PropertyDetails> OriginalList
which I clone it to another list by : List<PropretyDetails> CopiedList = OriginalList.ToList();
Now I pass the CopiedList
to some method that alters it.
Myproblem is the alterations are reflected to the OriginalList
A reference type is really a pointer to an object. And because PropertyDetails is also a reference type, copying the list just gives you a new list of pointers that point to the original objects. As Habbib pointed out, you'll have to create copies of the objects in the list, and build a new list that contains these copies.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments