using System.Collections.Generic;
public static class Program
public static void Main()
var list = new List<long> { 1, 2, 3, 1, 1, 1, 2, 10};
var exc = new List<long> { 1, 2, 3 };
var result = list.ExceptUnique(exc);
Console.WriteLine("Count = " + result.Count().ToString());
foreach(var item in result)
private static IEnumerable<T> ExceptUnique<T>(this IEnumerable<T> source, IEnumerable<T> except) where T : struct
var exceptList = except.ToList();
return source.Where(x => Compare(exceptList.PopFirstOrDefault(e => Compare(e, x)), default)).ToList();
private static T PopFirstOrDefault<T>(this IList<T> source, Func<T, bool> predicate) where T : struct
var item = source.FirstOrDefault(predicate);
if (!Compare(item, default))
private static bool Compare<T>(T x, T y) where T : struct
return EqualityComparer<T>.Default.Equals(x, y);