Method Exactly
View SourceExactly<T>(IAsyncEnumerable<T>, int, CancellationToken)
Determines whether or not the number of elements in the sequence is equals to the given integer.
Declaration
public static ValueTask<bool> Exactly<T>(this IAsyncEnumerable<T> source, int count, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<T> | source | The source sequence |
int | count | The exactly 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 equals to the given integer or false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Element type of sequence |
Examples
var numbers = new[] { 123, 456, 789 };
var result = numbers.Exactly(3);
The <code>result</code> variable will contain <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">true</a>.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|