Skip to content

Instantly share code, notes, and snippets.

@sebnilsson
Last active December 15, 2015 02:18
Show Gist options
  • Save sebnilsson/5185887 to your computer and use it in GitHub Desktop.
Save sebnilsson/5185887 to your computer and use it in GitHub Desktop.
Distinct enumerable through LINQ-group by
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