Try the following:
bool sameLength = (collections.Select(c => c.Count()) .Distinct() .Take(2)
or
bool sameLength = !collections.Select(c => c.Count()).Distinct().Skip(1).Any();
It works by checking the length of each collection and tracking unique values. Having one reporting account is in order, but if there are two (or more) different calculations, then all collections do not have the same length, so the result will be false.
Update. If collections are of different types, you can use a non-generic interface, as shown in this answer .
var collections = new List<ICollection> { a, b, c, d };
Mark byers
source share