The sixth video in my Exploring MoreLINQ series looks at the
TakeEvery extension methods, which add to the capabilities of the standard LINQ
TakeLast allows you to take items from the end of a sequence,
TakeEvery allows you to sample items from a sequence (e.g. take every third item), and
TakeUntil is subtly different from LINQ's
TakeWhile in that it includes the first item that matches the predicate. This simple example highlights the difference between the two:
"AAABBB".TakeWhile(c => c == 'A') // returns A,A,A "AAABBB".TakeUntil(c => c != 'A') // returns A,A,A,B
You can find all videos in this series here.