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

后端 未结 11 1892
萌比男神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:13

    Your target variable is a reference type. This means that anything you do to it will be reflected in the list you pass into it.

    To not do that, you are going to need to create a new list in the method, copy target contents to it, and then perform the remove at operation on the new list.

    About Reference and Value Types

提交回复
热议问题