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
Build a new list first and operate on that, because List is a reference type, i.e. when you pass it in a function, you do not just pass the value but the actual object itself.
If you just assign target to mainList, both variables point to the same object, so you need to create a new List:
List- target = new List
- (mainList);
void List makes no sense, because either you return nothing (void) or you return a List. So either remove the return statement from your method or return a new List. In the latter case, I would rewrite this as:
List- target = SomeOperationFunction(mainList);
List
- SomeOperationFunction(List
- target)
{
var newList = new List
- (target);
newList.RemoveAt(3);
return newList;
}