If so, what is it?
EDIT: In response to comment below:
var tabulatedOutputErrors = from error in outputErrors
group error by error into errorGroup
select new { error = errorGroup.Key, number = errorGroup.Count() };
var tabulatedInputErrors = from error in inputErrors
group error by error into errorGroup
select new { error = errorGroup.Key, number = errorGroup.Count() };
var problems = tabulatedOutputErrors.Except(tabulatedInputErrors);
You can expand out the counts if you need to.
LINQ has the
Enumerable.Exceptextension method, which seems to be what you’re looking for.Example:
Alternative:
From .NET 3.5 onwards there also exists the
HashSet<T>class (and also the similarSortedSet<T>class in .NET 4.0. This class (or rather theISet<T>interface in .NET 4.0) has anExceptWithmethod which could also do the job.Example:
Of course, it depends on the context/usage whether this approach is more desirable. The efficiency benefit (doing the difference operation in-place and using hash codes) in most cases is probably negligible. Either way, take your pick. 🙂