Method IndexOf
View SourceIndexOf<TSource>(IAsyncEnumerable<TSource>, TSource, CancellationToken)
Searches for the specified object and returns the zero-based index of the first occurrence within the entire IAsyncEnumerable<T>.
Declaration
public static ValueTask<int> IndexOf<TSource>(this IAsyncEnumerable<TSource> source, TSource item, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The source sequence. |
TSource | item | The object to locate in the IAsyncEnumerable<T>. The value can be null for reference types. |
CancellationToken | cancellationToken | The optional cancellation token to be used for cancelling the sequence at any time. |
Returns
Type | Description |
---|---|
ValueTask<int> | The zero-based index of the first occurrence of |
Type Parameters
Name | Description |
---|---|
TSource | The type of elements of |
Remarks
The IAsyncEnumerable<T> is searched forward starting at the first element and ending at the last element.
This method determines equality using the default equality comparer Default
for TSource
, the type of values in the list.
This operator executes immediately.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
IndexOf<TSource>(IAsyncEnumerable<TSource>, TSource, Index, CancellationToken)
Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the IAsyncEnumerable<T> that extends from the specified index to the last element.
Declaration
public static ValueTask<int> IndexOf<TSource>(this IAsyncEnumerable<TSource> source, TSource item, Index index, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The source sequence. |
TSource | item | The object to locate in the IAsyncEnumerable<T>. The value can be null for reference types. |
Index | index | The Index of the starting element within the sequence. |
CancellationToken | cancellationToken | The optional cancellation token to be used for cancelling the sequence at any time. |
Returns
Type | Description |
---|---|
ValueTask<int> | The zero-based index of the first occurrence of |
Type Parameters
Name | Description |
---|---|
TSource | The type of elements of |
Remarks
The IAsyncEnumerable<T> is searched forward starting at index
and ending at the
last element.
This method determines equality using the default equality comparer Default
for TSource
, the type of values in the list.
This operator executes immediately.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
IndexOf<TSource>(IAsyncEnumerable<TSource>, TSource, Index, int, CancellationToken)
Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the IAsyncEnumerable<T> that starts at the specified index to the last element and contains the specified number of elements.
Declaration
public static ValueTask<int> IndexOf<TSource>(this IAsyncEnumerable<TSource> source, TSource item, Index index, int count, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The source sequence. |
TSource | item | The object to locate in the IAsyncEnumerable<T>. The value can be null for reference types. |
Index | index | The Index of the starting element within the sequence. |
int | count | The number of elements in the section to search. |
CancellationToken | cancellationToken | The optional cancellation token to be used for cancelling the sequence at any time. |
Returns
Type | Description |
---|---|
ValueTask<int> | The zero-based index of the first occurrence of |
Type Parameters
Name | Description |
---|---|
TSource | The type of elements of |
Remarks
The IAsyncEnumerable<T> is searched forward starting at index
and ending at
index
plus count
minus 1
, if count is greater than 0
.
This method determines equality using the default equality comparer Default
for TSource
, the type of values in the list.
This operator executes immediately.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|