Issue where modifying List A also modifies List B
Reference Article
Today, while programming, I performed list conversion and simultaneously deleted items from the converted list.
1 | List<XYZ> A = firList; |
I found that after deleting from A, the firList was also deleted.
The specific reason hasn’t been investigated clearly yet. I assume it’s because of memory usage, causing both lists to operate simultaneously. The exact reason is not verified, leaving a note to update later.
1 | List<XYZ> newFirList = new List<XYZ>(); |
Later, I used the clone operation on the firList so that the values of the two lists would not affect each other.
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.


