using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace New_College { public static class DistinctByHelper { public static IEnumerable DistinctBy(this IEnumerable source, Func keySelector) { HashSet seenKeys = new HashSet(); foreach (var item in source) { if (seenKeys.Add(keySelector(item))) { yield return item; } } } } }