标签:方法重写 hash key his ati 方法 ble ret add
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> hashSet = new HashSet<TKey>();
foreach (TSource element in source)
{
if (hashSet.Add(keySelector(element)))
{
yield return element;
}
}
}
标签:方法重写 hash key his ati 方法 ble ret add
原文地址:https://www.cnblogs.com/chensong0524/p/10755018.html