Right, so I have an enumerable and wish to get distinct values from it.
Using System.Linq
, there\'s of course an extension method called Distinct<
Here's a simple extension method that does what I need...
public static class EnumerableExtensions
{
public static IEnumerable Distinct(this IEnumerable source, Func selector)
{
return source.GroupBy(selector).Select(x => x.Key);
}
}
It's a shame they didn't bake a distinct method like this into the framework, but hey ho.