ContainsAny - Kalkwst/Risotto GitHub Wiki
Determines whether the first sequence contains any of the elements of the second sequence, optionally using a custom equality comparer.
In this page
- Definition
- Overloads
- ContainsAny(IEnumerable target)
- ContainsAny(IEnumerable target, IEqualityComparer? comparer)
Overload | Description |
---|---|
ContainsAny(IEnumerable target) | Determines whether source sequence contains any of the elements of target sequence. |
ContainsAny(IEnumerable target, IEqualityComparer? comparer) | Determines whether source sequence contains any of the elements of target sequence using the provided comparer
|
Determines whether source
sequence contains any of the elements of target
sequence using the default comparer.
public static bool ContainsAny<TSource>(this IEnumerable<TSource> source, IEnumerable<TSource> target);
TSource
The type of the elements of source
source
IEnumerable <TSource>
A sequence to check if contains any element of the target
.
target
IEnumerable <TSource>
A sequence to check if any of its elements are contained in source
.
true
source
contains any element of the target
sequence, false
otherwise.
ArgumentNullException
source
is null
-or-
target
is null
The following code example demonstrates how to use ContainsAny(IEnumerable target) to determine if source
contains any elements of the target
sequence.
var source = new int[]{ 1, 2, 3, 4, 5 };
var target = new int[]{ 1, 2, 6 };
source.ContainsAny(target);
//=> true
Determines whether source
sequence contains any of the elements of target
sequence using an optional custom equality comparer
.
public static bool ContainsAny<TSource>(this IEnumerable<TSource> source, IEnumerable<TSource> target, IEqualityComparer<TSource>? comparer);
TSource
The type of the elements of source
source
IEnumerable <TSource>
A sequence to check if contains any element of the target
.
target
IEnumerable <TSource>
A sequence to check if any of its elements are contained in source
.
comparer
IEqualityComparer
An equality comparer to compare values.
true
source
contains any element of the target
sequence, false
otherwise.
ArgumentNullException
source
is null
-or-
target
is null
The following code example demonstrates how to use ContainsAny(IEnumerable target) to determine if source
contains any elements of the target
sequence.
var source = new string[]{ "a", "b", "c" };
var target = new string[]{ "a", "B", "Ducks" };
source.ContainsAny(target, StringComparer.OrdinalIgnoreCase);
//=> true