ContainsAll - Kalkwst/Risotto GitHub Wiki
Determines whether all of the elements of the target
sequence exist in the source
sequence, optionally using a custom comparer
.
In this page
- Definition
- Overloads
- ContainsAll(IEnumerable target)
- ContainsAll(IEnumerable target, IEqualityComparer? comparer)
Overload | Description |
---|---|
ContainsAll(IEnumerable target) | Determines whether target is a subset of source . |
[ContainsAll(IEnumerable target, IEqualityComparer? comparer) | Determines whether target is a subset of source , using a custom comparer
|
Determines whether all of the elements of the target
sequence exist in the source
sequence.
public static bool ContainsAll<TSource>(this IEnumerable<TSource> source, IEnumerable<TSource> target);
TSource
The type of the elements of source
.
source
IEnumerable <TSource>
The sequence to compare with target
.
target
IEnumerable <TSource>
The sequence to see if is a subset of source
.
true
if target
is a subset of source
, false
otherwise.
ArgumentNullException
source
is null
The following code example demonstrates how to use ContainsAll(IEnumerable target) to determine if target
is a subset of source
.
var odds = new int[]{1, 3, 5};
var one = new int[]{1};
var two = new int[]{2};
odds.ContainsAll(one);
//=> true
odds.ContainsAll(two);
//=> false
Determines whether all of the elements of the target
sequence exist in the source
sequence, based on a custom equality comparer
.
TSource
The type of the elements of source
.
source
IEnumerable <TSource>
The sequence to compare with target
.
target
IEnumerable <TSource>
The sequence to see if is a subset of source
.
comparer
IEqualityComparer
An equality comparer to compare values.
true
if target
is a subset of source
, false
otherwise.
ArgumentNullException
source
is null
-or-
comparer
is null
The following code example demonstrates how to use ContainsAll(IEnumerable target, IEqualityComparer? comparer) to determine if target
is a subset of source
.
var source = new string[]{ "a", "b", "C", "d", "e" };
var target = new string[]{"A", "c", "d"};
source.ContainsAll(target, StringComparer.OrdinalIgnoreCase);
//=> true