I have two collections of type ICollection called c1 and c2. I\'d like to find the set of items that are in c2
public class MyTypeComparer : IEqualityComparer
{
public MyTypeComparer()
{
}
#region IComparer Members
public bool Equals(MyType x, MyType y)
{
return string.Equals(x.Id, y.Id);
}
public int GetHashCode(MyType obj)
{
return base.GetHashCode();
}
#endregion
}
Then, using Linq:
c3 collection = new collection().add(c1);
c3.add(c2);
var items = c3.Distinct(new MyTypeComparer());
You could also do it using generics and predicates. If you need a sample, let me know.