In C# is there a function that correlates sequential values on a IEnumerable
- by Mike Q
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.