{TOC}
| Namespace: | System.Linq |
| Assembly: | System.Core.dll |
| Extends: | IEnumerable<T> |
Back to
Standard Query Operator IndexEditIntroduction
The Reverse operator reverses the elements of a sequence.
EditMethod Signatures
public static IEnumerable<TSource> Reverse<TSource>(
this IEnumerable<TSource> source)EditExceptions
Throws an ArgumentNullException if
source is null.
EditPseudo-code
If
source is null, throw an ArgumentNullException.
Copy
source into a local array
TSource[] called buffer.
Iterate through the buffer in reverse order (by index position. i.e. count-1 to 0).
Return the current element. Resume execution from here when the next element is requested.
EditLoop Count
1. A local array copy of the source sequence is generated, then each element is returned when iterated. 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.