Now I come a stage to get all my data as a list in cache(objects) and my next thing I have to do is to remove some instances from the list.
Normally, I would do removing
Maybe you're trying to do something like this?
List firstList;
List toBeRemovedItems;
List finalList;
foreach(T item in firstList)
{
toBeRemovedItems = CheckIfWeRemoveThisOne(item.Number, item.Id);
if (toBeRemovedItems == null && toBeRemovedItems.Count() == 0)
finalList.Add(item);
}
This is how I managed to solve an issue with getting rid of duplicates between a List and a List. I used the CheckIfWeRemoveThisOne function to check if the item.Number belonged to some other item, using the ID as the defining characteristic. If it found another item (a duplicate), rather than try and remove it from the original list (which I was getting back a List and was given a List into my function in the first place, so I had my doubts as to how I could do it, anyway), I just built a new list -- adding the result into it if it was found to be ok.