public static IEnumerable <T> Subtraction <T>(IEnumerable <T> enumerable1, IEnumerable <T> enumerable2, Comparison <T> compare = null) { XContract.ArgIsNotNull(enumerable1, nameof(enumerable1)); XContract.ArgIsNotNull(enumerable2, nameof(enumerable2)); if (compare == null) { compare = (x, y) => Obj.AreEquals(x, y) ? 0 : 1; } enumerable1 = enumerable1.ToList(); if (!enumerable1.Any()) { return(new T[0]); } enumerable2 = enumerable2.ToList(); var result = new List <T>(); ForEach( enumerable1, c => { // ReSharper disable SimplifyLinqExpression if (!enumerable2.Any(x => compare(c, x) == 0)) // ReSharper restore SimplifyLinqExpression { result.Add(c); } }); return(result.ToArray()); }