Created
April 14, 2017 12:59
-
-
Save code-atom/3b6cac1c1e0b3647749efa0427202941 to your computer and use it in GitHub Desktop.
List Intersect Method Extension.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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