Method CountBetween
View SourceCountBetween<T>(IAsyncEnumerable<T>, int, int, CancellationToken)
Determines whether or not the number of elements in the sequence is between an inclusive range of minimum and maximum integers.
Declaration
public static ValueTask<bool> CountBetween<T>(this IAsyncEnumerable<T> source, int min, int max, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<T> | source | The source sequence |
int | min | The minimum number of items a sequence must have for this function to return true |
int | max | The maximum number of items a sequence must have for this function to return true |
CancellationToken | cancellationToken | The optional cancellation token to be used for cancelling the sequence at any time. |
Returns
Type | Description |
---|---|
ValueTask<bool> | true if the number of elements in the sequence is between (inclusive) the min and max given integers or false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Element type of sequence |
Examples
var numbers = new[] { 123, 456, 789 };
var result = numbers.CountBetween(1, 2);
The <code>result</code> variable will contain <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">false</a>.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|