CSharp examples for System.Collections.Generic:IEnumerable
Get Duplicates from IEnumerable
using System.Linq; using System.Collections.Generic; using System;// ww w. ja v a2s . co m public class Main{ public static IEnumerable<T1> GetDuplicates<T1, T2>(this IEnumerable<T1> collection, Func<T1, T2> selector) { return collection.GroupBy(selector).Where(group => group.Count() > 1).SelectMany(group => group); } }