public static IEnumerable <TSource> Intersect <TSource, TCompareKey>(this IEnumerable <TSource> first, IEnumerable <TSource> second, Func <TSource, TCompareKey> compareKeySelector) { return(first.Intersect(second, AnonymousComparer.Create(compareKeySelector))); }
/// <summary> /// Returns all items in the first collection that intersect the ones in the second collection that match the lambda condition. /// </summary> /// <typeparam name="T">The type.</typeparam> /// <param name="listA">The first list.</param> /// <param name="listB">The second list.</param> /// <param name="lambda">The filter expression.</param> /// <returns>The filtered list.</returns> public static IEnumerable <T> Intersect <T>(this IEnumerable <T> listA, IEnumerable <T> listB, Func <T, T, bool> lambda) => listA.Intersect(listB, new LambdaComparer <T>(lambda));
public static IEnumerable <T> Intersect <T>(this IEnumerable <T> source, IEnumerable <T> second, Func <T, T, bool> predicate) { return(source.Intersect(second, new PredicateEqualityComparer <T>(predicate))); }
/// <summary> /// Returns the elements that appear in each of the two sequences, using a lambda expression as an equality comparer. /// </summary> /// <typeparam name="T">The type of each item in the sequence</typeparam> /// <param name="sequence1">The first sequence</param> /// <param name="sequence2">The second sequence</param> /// <param name="comparer">A lamda expression used to test two objects of the same type for equality.</param> /// <returns>An <see cref="IEnumerable{T}"/> of distinct elements from the original sequence.</returns> /// <exception cref="NullReferenceException">If sequence1 is null.</exception> /// <exception cref="NullReferenceException">If sequence2 is null.</exception> /// <exception cref="ArgumentNullException">If the comparer is null.</exception> public static IEnumerable <T> Intersect <T>(this IEnumerable <T> sequence1, IEnumerable <T> sequence2, Func <T, T, bool> comparer) { return(sequence1.Intersect(sequence2, new LambdaComparer <T>(comparer))); }