Skip to content

Instantly share code, notes, and snippets.

@code-atom
Created April 14, 2017 12:59
Show Gist options
  • Save code-atom/3b6cac1c1e0b3647749efa0427202941 to your computer and use it in GitHub Desktop.
Save code-atom/3b6cac1c1e0b3647749efa0427202941 to your computer and use it in GitHub Desktop.
List Intersect Method Extension.
public static class ListExtension
{
public static IEnumerable<TObject> Intersect<TObject>(this IEnumerable<TObject> source, IEnumerable<TObject> destination, Func<TObject, TObject, bool> predicate)
{
var result = new List<TObject>();
foreach (var sourceObject in source)
{
foreach (var destinationObject in destination)
{
if (predicate(sourceObject, destinationObject))
result.Add(destinationObject);
}
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment