public static IEnumerable<TSource> SkipUntil<TSource>(
this IEnumerable<TSource> source,
Func<TSource, bool> predicate
)
<ExtensionAttribute>
Public Shared Function SkipUntil(Of TSource) (
source As IEnumerable(Of TSource),
predicate As Func(Of TSource, Boolean)
) As IEnumerable(Of TSource)
public:
[ExtensionAttribute]
generic<typename TSource>
static IEnumerable<TSource>^ SkipUntil(
IEnumerable<TSource>^ source,
Func<TSource, bool>^ predicate
)
[<ExtensionAttribute>]
static member SkipUntil :
source : IEnumerable<'TSource> *
predicate : Func<'TSource, bool> -> IEnumerable<'TSource>
SkipUntil differs from Enumerable.SkipWhile in two respects. Firstly, the sense of the predicate is reversed: it is expected that the predicate will return false to start with, and then return true - for example, when trying to find a matching item in a sequence.
Secondly, SkipUntil skips the element which causes the predicate to return true. For example, in a sequence
{ 1, 2, 3, 4, 5 }
x => x == 3
{ 4, 5 }
SkipUntil is as lazy as possible: it will not iterate over the source sequence until it has to, it won't iterate further than it has to, and it won't evaluate the predicate until it has to. (This means that an item may be returned which would actually cause the predicate to throw an exception if it were evaluated, so long as it comes after the first item causing the predicate to return true.)
ArgumentNullException | source or predicate is null |