Last active
December 15, 2015 02:18
-
-
Save sebnilsson/5185887 to your computer and use it in GitHub Desktop.
Distinct enumerable through LINQ-group by
This file contains 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 IEnumerable<TSource> Distinct<TSource>( | |
this IEnumerable<TSource> source, Func<TSource, object> predicate) | |
{ | |
return from item in source.GroupBy(predicate) select item.First(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment