leora
leora

Reputation: 196459

In C#, what is the fastest way to remove one collection from another Collection?

I have two collections that are both:

 List<MyObject>
  1. fullCollection
  2. oldCollection

I want to find out which objects are in the full list but not the other list. What is the fastest ways to do something like this:

var inOneButNotTheOther = 
    fullCollection.Remove(oldCollection, new MyObjectComparer());

Upvotes: 2

Views: 130

Answers (1)

usr
usr

Reputation: 171178

fullCollection.Except(oldCollection, new MyObjectComparer())

Upvotes: 3

Related Questions