Method CopyTo
CopyTo<TSource>(IAsyncEnumerable<TSource>, IList<TSource>, CancellationToken)
Copies the contents of a sequence into a provided list.
Declaration
public static ValueTask<int> CopyTo<TSource>(this IAsyncEnumerable<TSource> source, IList<TSource> list, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerable<TSource> | source | The source sequence. |
| IList<TSource> | list | The list that is the destination of the elements copied from |
| CancellationToken | cancellationToken | The CancellationToken in use. |
Returns
| Type | Description |
|---|---|
| ValueTask<int> | The number of elements actually copied. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of elements of |
Remarks
All data from source will be copied to list, starting at position 0.
This operator executes immediately.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentNullException |
|
CopyTo<TSource>(IAsyncEnumerable<TSource>, IList<TSource>, int, CancellationToken)
Copies the contents of a sequence into a provided list.
Declaration
public static ValueTask<int> CopyTo<TSource>(this IAsyncEnumerable<TSource> source, IList<TSource> list, int index, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerable<TSource> | source | The source sequence. |
| IList<TSource> | list | The list that is the destination of the elements copied from |
| int | index | The position in |
| CancellationToken | cancellationToken | The CancellationToken in use. |
Returns
| Type | Description |
|---|---|
| ValueTask<int> | The number of elements actually copied. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of elements of |
Remarks
All data from source will be copied to list, starting at position
index.
This operator executes immediately.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentNullException |
|