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.
Written by James Long
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#C#
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#