{TOC}
| Namespace: | System.Linq |
| Assembly: | System.Core.dll |
| Extends: | IEnumerable<T> |
Back to
Standard Query Operator IndexEditIntroduction
The Take operator yields a given number of elements from a sequence and then skips the remainder of the sequence.
EditMethod Signatures
public static IEnumerable<TSource> Take<TSource>(
this IEnumerable<TSource> source,
int count)EditExceptions
Throws an ArgumentNullException if
source is null.
EditPseudo-code
If
source is null, throw an ArgumentNullException.
If
count > 0.
Iterate the source sequence.
If count is equal to zero then exit.
Return the current element. Resume execution from this point when the next element is requested.
Decrement count by one.
EditLoop Count
This operator implements the standard
deferred execution iterator pattern. This means, no looping will occur until the result is iterated over.
EditCode Samples
TODO: Needs code sample.