In C# is there a function that correlates sequential values on a IEnumerable
Posted
by Mike Q
on Stack Overflow
See other posts from Stack Overflow
or by Mike Q
Published on 2010-03-24T16:09:46Z
Indexed on
2010/03/24
16:13 UTC
Read the original article
Hit count: 227
Hi all,
I have a IEnumerable. I have a custom Interval class which just has two DateTimes inside it. I want to convert the IEnumerable to IEnumerable where n DateTimes would enumerate to n-1 Intervals.
So if I had 1st Jan, 1st Feb and 1st Mar as the DateTime then I want two intervals out, 1st Jan/1st Feb and 1st Feb/1st March.
Is there an existing C# Linq function that does this. Something like the below Correlate...
IEnumerable<Interval> intervals = dttms.Correlate<DateTime, Interval>((dttm1, dttm2) => new Interval(dttm1, dttm2));
If not I'll just roll my own.
© Stack Overflow or respective owner