Last Updated: February 25, 2016
·
623
· mauricetheferre

Quick Subset in C#

I always try to eek the most out of IEnumerable extension methods. Here is a gem I found on Stack Overflow:

bool bIsSubset = !IEnumerable2.Except(IEnumerable1).Any();

Instead of two forloops tracking if all the members in IEnumerable2 exist in IEnumerable1, the above command can do it all in one line.