score:11

Accepted answer

Use Enumerable.Intersect:

var newList = OldIDs.Intersect(NewIDs).ToList();

If OldIDs contains a custom object with an Id property:

var newList = OldIDs.Where(x => NewIDs.Contains(x.Id)).ToList();

another, possibly more efficient way using Join:

var oldInNew = from old in OldIDs
               join newID in NewIDs 
               on old.Id equals newID
               select old;
var newList = oldInNew.ToList();

score:2

You want to use Intersect(), try the following:

var intersectedList = NewIDs.Intersect(OldIDs).ToList();

Related Articles