score:5

Accepted answer

removeall modifies your existing list, it returns the number of items it removed. to get a new list without the items you can use

var newlist = mylist.where(i => !excludeditems.any(ei => ei.id == i.id)).tolist();

although if your server class has the right equality members to compare ids, you could just write

var newlist = mylist.except(servers).tolist();

score:1

try this

list<target> allservers = gettargets(group.id);
list<long> excludedservers = getexcludedservers();

list<target> patchservers = allservers
    .where(x => !excludedservers.any(y => y.id == x.id)).tolist();

score:1

you could do something like this

patchservers = allservers.where(x => !excludedservers.contains(x.id)).tolist();

Related Query

More Query from same tag