AsyncEnumerable.Take Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Take<TSource>(IAsyncEnumerable<TSource>, Int32) |
Returns a specified number of contiguous elements from the start of a sequence. |
Take<TSource>(IAsyncEnumerable<TSource>, Range) |
Returns a specified range of contiguous elements from a sequence. |
Take<TSource>(IAsyncEnumerable<TSource>, Int32)
- Source:
- Take.cs
Returns a specified number of contiguous elements from the start of a sequence.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IAsyncEnumerable<TSource> ^ Take(System::Collections::Generic::IAsyncEnumerable<TSource> ^ source, int count);
public static System.Collections.Generic.IAsyncEnumerable<TSource> Take<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, int count);
static member Take : System.Collections.Generic.IAsyncEnumerable<'Source> * int -> System.Collections.Generic.IAsyncEnumerable<'Source>
<Extension()>
Public Function Take(Of TSource) (source As IAsyncEnumerable(Of TSource), count As Integer) As IAsyncEnumerable(Of TSource)
Type Parameters
- TSource
The type of the elements of source.
Parameters
- source
- IAsyncEnumerable<TSource>
The sequence to return elements from.
- count
- Int32
The number of elements to return.
Returns
An IAsyncEnumerable<T> that contains the specified number of elements from the start of the input sequence.
Exceptions
source
is null
.
Applies to
Take<TSource>(IAsyncEnumerable<TSource>, Range)
- Source:
- Take.cs
Returns a specified range of contiguous elements from a sequence.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IAsyncEnumerable<TSource> ^ Take(System::Collections::Generic::IAsyncEnumerable<TSource> ^ source, Range range);
public static System.Collections.Generic.IAsyncEnumerable<TSource> Take<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Range range);
static member Take : System.Collections.Generic.IAsyncEnumerable<'Source> * Range -> System.Collections.Generic.IAsyncEnumerable<'Source>
<Extension()>
Public Function Take(Of TSource) (source As IAsyncEnumerable(Of TSource), range As Range) As IAsyncEnumerable(Of TSource)
Type Parameters
- TSource
The type of the elements of source
.
Parameters
- source
- IAsyncEnumerable<TSource>
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
An IAsyncEnumerable<T> that contains the specified range
of elements from the source
sequence.
Exceptions
source
is null
.
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 enumerates source
and yields elements whose indices belong to the specified range
.