I have two multisets, both IEnumerables, and I want to compare them.
string[] names1 = { \"tom\", \"dick\", \"harry\" };
string[] names2 = { \
@cdhowie's answer is great, but here's a nice trick that makes it even better for types that declare .Count by comparing that value prior to decomposing parameters to IEnumerable. Just add this to your code in addition to his solution:
public static bool UnsortedSequencesEqual(this IReadOnlyList first, IReadOnlyList second, IEqualityComparer comparer = null)
{
if (first.Count != second.Count)
{
return false;
}
return UnsortedSequencesEqual((IEnumerable)first, (IEnumerable)second, comparer);
}