Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var subset = new[] { 2, 4, 6, 8 };
- var superset = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- superset.Intersect(subset).Count() == subset.Count()
- bool contained = !subset.Except(superset).Any();
- HashSet<int> hashSet = new HashSet<int>(superset);
- bool contained = subset.All(i => hashSet.Contains(i));
- subset.Except(superset).Count() == 0
- public static bool ContainsAll<T>(this IEnumerable<T> source, IEnumerable<T> values)
- {
- return values.All(value => source.Contains(value));
- }
Add Comment
Please, Sign In to add comment