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

后端 未结 11 1888
萌比男神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 09:16

    Just make sure that you initialize the new list with a list created by copying the elements of the source list.

    List target = mainList; Should be List target = new List(mainList);

提交回复
热议问题