|  | @@ -1,4 +1,5 @@
 | 
	
		
			
				|  |  |  #nullable enable
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  using System;
 | 
	
		
			
				|  |  |  using System.Collections.Generic;
 | 
	
		
			
				|  |  |  using System.Linq;
 | 
	
	
		
			
				|  | @@ -10,19 +11,24 @@ namespace Masuit.Tools
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  |      public static partial class IEnumerableExtensions
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  | -        ///// <summary>
 | 
	
		
			
				|  |  | -        ///// 按字段去重
 | 
	
		
			
				|  |  | -        ///// </summary>
 | 
	
		
			
				|  |  | -        ///// <typeparam name="TSource"></typeparam>
 | 
	
		
			
				|  |  | -        ///// <typeparam name="TKey"></typeparam>
 | 
	
		
			
				|  |  | -        ///// <param name="source"></param>
 | 
	
		
			
				|  |  | -        ///// <param name="keySelector"></param>
 | 
	
		
			
				|  |  | -        ///// <returns></returns>
 | 
	
		
			
				|  |  | -        //public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
 | 
	
		
			
				|  |  | -        //{
 | 
	
		
			
				|  |  | -        //    var hash = new HashSet<TKey>();
 | 
	
		
			
				|  |  | -        //    return source.Where(p => hash.Add(keySelector(p)));
 | 
	
		
			
				|  |  | -        //}
 | 
	
		
			
				|  |  | +#if NET6_0
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// 按字段去重
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        /// <typeparam name="TSource"></typeparam>
 | 
	
		
			
				|  |  | +        /// <typeparam name="TKey"></typeparam>
 | 
	
		
			
				|  |  | +        /// <param name="source"></param>
 | 
	
		
			
				|  |  | +        /// <param name="keySelector"></param>
 | 
	
		
			
				|  |  | +        /// <returns></returns>
 | 
	
		
			
				|  |  | +        public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            var hash = new HashSet<TKey>();
 | 
	
		
			
				|  |  | +            return source.Where(p => hash.Add(keySelector(p)));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  |          /// 添加多个元素
 | 
	
	
		
			
				|  | @@ -594,4 +600,4 @@ namespace Masuit.Tools
 | 
	
		
			
				|  |  |              return (news.Where(c => olds.All(m => keySelector(m) != keySelector(c))), olds.Where(m => news.All(c => keySelector(c) != keySelector(m))), olds.Where(m => news.Any(c => keySelector(m) == keySelector(c))));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | +}
 |