Let's say I have following data:
Time Status 10:00 On 11:00 Off 12:00 Off 13:00 Off 14:00 Off 15:00 On 16:00 On
How could I group that using Linq into something like
[On, [10:00]], [Off, [11:00, 12:00, 13:00, 14:00]], [On, [15:00, 16:00]]
Create a GroupAdjacent extension, such as the one listed here.
GroupAdjacent
And then it's as simple as:
var groups = myData.GroupAdjacent(data => data.OnOffStatus);
1.4m articles
1.4m replys
5 comments
57.0k users