New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of .NET40
C#
public static IEnumerable<TSource> Distinct<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> selector)
{
    return source.Distinct(new SelectorEqualityComparer<TSource, TKey>(selector));
}
by Paulo Morgado   April 10, 2010 @ 5:22am
85 Views
no comments
 
C#
public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source, Func<TSource, TSource, bool> predicate)
{
    return source.Distinct(new PredicateEqualityComparer<TSource>(predicate));
}
by Paulo Morgado   April 10, 2010 @ 5:21am
89 Views
no comments
 
C#
[Serializable]
public class SelectorEqualityComparer<TSource, Tkey> : EqualityComparer<TSource>
{
    private Func<TSource, Tkey> selector;
 
    public SelectorEqualityComparer(Func<TSource, Tkey> selector)
        : base()
    {
        this.selector = selector;
    }
by Paulo Morgado   April 10, 2010 @ 5:18am
Tags: C#, .NET, .NET35, .NET40
94 Views
no comments
 
C#
[Serializable]
public class PredicateEqualityComparer<T> : EqualityComparer<T>
{
    private Func<T, T, bool> predicate;
 
    public PredicateEqualityComparer(Func<T, T, bool> predicate)
        : base()
    {
        this.predicate = predicate;
    }
by Paulo Morgado   April 10, 2010 @ 5:12am
Tags: C#, .NET, .NET35, .NET40
61 Views
no comments
 
brought to you by:
West Wind Techologies


If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate