I have a very long list of Ids (integers) that represents all the items that are currently in my database:
var idList = GetAllIds();
I also hav
Assuming the following premises are true:
idList
and itemsToAdd
may not contain duplicate valuesyou could use a HashSet
var itemsToAddSet = new HashSet(itemsToAdd);
itemsToAddSet.ExceptWith(idList);
According to the documentation the ISet
This method is an O(n) operation, where n is the number of elements in the other parameter.
In your case n
is the number of items in idList
.