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
You need to clone your list in your method, because List is a class, so it's reference-type and is passed by reference.
For example:
List- SomeOperationFunction(List
- target)
{
List
- tmp = target.ToList();
tmp.RemoveAt(3);
return tmp;
}
Or
List- SomeOperationFunction(List
- target)
{
List
- tmp = new List
- (target);
tmp.RemoveAt(3);
return tmp;
}
or
List- SomeOperationFunction(List
- target)
{
List
- tmp = new List
- ();
tmp.AddRange(target);
tmp.RemoveAt(3);
return tmp;
}