How do I change my new list without changing the original list?

后端 未结 11 1893
萌比男神i
萌比男神i 2020-12-03 08:30

I have a list that gets filled in with some data from an operation and I am storing it in the memory cache. Now I want another list which contains some sub data from the li

11条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 08:50

    Instead of assigning mainList to target, I would do: target.AddRange(mainList);

    Then you will have a copy of the items instead of a reference to the list.

提交回复
热议问题