.NET by Patrik

Collections & Memory Behavior

...see more

In .NET, when you assign one list (list2) to another list (list1) directly, both lists will reference the same memory location. As a result, any modifications made to list2 will also affect list1. To create a separate copy of the list, you should use the List<T> constructor to initialize a new list based on the elements of the original list (list1).

Comments