Method Take
View SourceTake<TSource>(IAsyncEnumerable<TSource>, Range)
Returns a specified range of contiguous elements from a sequence.
Declaration
public static IAsyncEnumerable<TSource> Take<TSource>(this IAsyncEnumerable<TSource> source, Range range)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence to return elements from. |
Range | range | The range of elements to return, which has start and end indexes either from the start or the end. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | An IEnumerable<T> that contains the specified |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its `GetEnumerator` method directly or by using `foreach` in Visual C# or `For Each` in Visual Basic.
Take<TSource>(IAsyncEnumerable<TSource>, Range) enumerates source
and yields elements whose indices belong to the specified range
.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|