Пример #1
0
        /// <summary>
        /// 自定义相交
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="first"></param>
        /// <param name="second"></param>
        /// <param name="comparer"></param>
        /// <returns></returns>
        public static IEnumerable <T> Intersect <T>(this IEnumerable <T> first, IEnumerable <T> second, Func <T, T, bool> comparer)
        {
            IEqualityComparer <T> comparerClass = new GeneralEqualityCompare <T>(comparer);

            return(Enumerable.Intersect <T>(first, second, comparerClass));
        }
Пример #2
0
        /// <summary>
        /// 自定义比较
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <param name="comparer"></param>
        /// <returns></returns>
        public static IEnumerable <T> Distinct <T>(this IEnumerable <T> data, Func <T, T, bool> comparer)
        {
            IEqualityComparer <T> eqComparer = new GeneralEqualityCompare <T>(comparer);

            return(Enumerable.Distinct <T>(data, eqComparer));
        }